2012-02-07 118 views
0

當我運行compieled .exe文件時,它顯示命令行,並且我希望刪除它..但我對C++一無所知,所以我不知道如何做到這一點?C++刪除命令行

這不是我的腳本...只是讓你知道。

#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; 
} 

回答

2
#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; 
    } 

應該工作。不要忘記頂部的定義。

+1

**這工作**,謝謝! - 已解決:) – JHolta 2012-02-07 03:00:25

+0

非常歡迎。 – Andonuts 2012-02-07 03:02:09

0

如果您希望刪除顯示命令行的部分,則任何以cout <<開頭的行都會在屏幕上顯示某些內容。

但是,命令行主要存儲在argv中,我在程序中沒有看到任何引用。

0

您需要編譯並將其鏈接到Windows子系統,而不是控制檯子系統。