简体   繁体   中英

C++ Removing the command-line

when i run the compieled .exe-file it shows the commandline, and I wish to remove it.. But I don't know nothing about C++, so I wonder how one can do it?

This is not my script... Just so you know.

#include <iostream>
#include <windows.h>

using namespace std;

typedef long (*GetFunctionCount) (void) __attribute__((stdcall));
typedef long (*GetFunctionInfo)(int, void*&, char*&) __attribute__((stdcall));
typedef void (*Setup)(char*,char*,long,long,char*) __attribute__((stdcall));

int main(int argc, char** argv) {
    HMODULE libsmart = LoadLibrary("./libsmart.dll");
    cout << "Library: " << libsmart << '\n';
    cout << "GetFunctionCount: " << (void*)GetProcAddress(libsmart, "GetFunctionCount") << '\n';
    cout << "GetFunctionInfo: " << (void*)GetProcAddress(libsmart, "GetFunctionInfo") << '\n';
    GetFunctionCount count = (GetFunctionCount) GetProcAddress(libsmart, "GetFunctionCount");
    GetFunctionInfo info = (GetFunctionInfo) GetProcAddress(libsmart, "GetFunctionInfo");

    int exports = count();
    cout << "#Exports = " << count() << '\n';
    for (int i = 0; i < exports; i++) {
        char* def = new char[1024];
        void* addr;
        info(i,addr,def);
        cout << '\t' << addr << " = " << def  << '\n';
        delete def;
    }
    cout << "Starting SMART...\n";
    Setup setup = (Setup) GetProcAddress(libsmart, "std_setup");
    setup((char*)"http://world19.runescape.com/", (char*)",f5", 765, 503,(char*)"");

    while (true) Sleep(1000);

    return 0;
}
#define _WIN32_WINNT 0x0500
#include <iostream>
#include <windows.h>



 using namespace std;

    typedef long (*GetFunctionCount) (void) __attribute__((stdcall));
    typedef long (*GetFunctionInfo)(int, void*&, char*&) __attribute__((stdcall));
    typedef void (*Setup)(char*,char*,long,long,char*) __attribute__((stdcall));

    int main(int argc, char** argv) {
    HWND hWnd = GetConsoleWindow();
    ShowWindow( hWnd, SW_HIDE );
        HMODULE libsmart = LoadLibrary("./libsmart.dll");
        cout << "Library: " << libsmart << '\n';
        cout << "GetFunctionCount: " << (void*)GetProcAddress(libsmart, "GetFunctionCount") << '\n';
        cout << "GetFunctionInfo: " << (void*)GetProcAddress(libsmart, "GetFunctionInfo") << '\n';
        GetFunctionCount count = (GetFunctionCount) GetProcAddress(libsmart, "GetFunctionCount");
        GetFunctionInfo info = (GetFunctionInfo) GetProcAddress(libsmart, "GetFunctionInfo");

        int exports = count();
        cout << "#Exports = " << count() << '\n';
        for (int i = 0; i < exports; i++) {
            char* def = new char[1024];
            void* addr;
            info(i,addr,def);
            cout << '\t' << addr << " = " << def  << '\n';
            delete def;
        }
        cout << "Starting SMART...\n";
        Setup setup = (Setup) GetProcAddress(libsmart, "std_setup");
        setup((char*)"http://world19.runescape.com/", (char*)",f5", 765, 503,(char*)"");

        while (true) Sleep(1000);

        return 0;
    }

Should work. Don't forget the definition at the top.

If you wish to remove the part that shows the commandline, any line that starts with cout << is showing something to the screen.

However, the command line is primarily stored in argv , and I don't see any reference to that in your program.

您将需要编译并将其链接到Windows子系统,而不是控制台子系统。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM