当我运行compieled .exe文件时,它会显示命令行,我希望将其删除..但我对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;
}
答案 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 :(得分:0)
如果您要删除显示命令行的部分,则任何以cout <<
开头的行都会向屏幕显示内容。
但是,命令行主要存储在argv
中,我在程序中看不到任何引用。
答案 2 :(得分:0)
您需要编译并将其链接到Windows子系统,而不是控制台子系统。