好的,这是这个问题的延续:How to make a simple Hello World "invisible" in Windows (C/C++)
人们给了我一些指导,我在这里提出了一个新问题:
在做了一些研究之后,我再次陷入困境。互联网上的人声称,仅创建一个 win32 应用程序将没有图形指示。
这是执行此操作的代码(我很确定您已经知道这一点,但是 w/e)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
//code
return 0;
}
因此在 main 中键入的代码不会显示出来。我真的不明白他们的意思是什么类型的代码,但例如:
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
while (1) {
}
}
这个程序弹出一个 Cmd 窗口就好了。
我还发现,通过像这样在 STARTUPINFO 结构中初始化值
STARTUPINFO StartupInfo;
memset(&StartupInfo, 0, sizeof(StartupInfo));
// set the size of the structure
StartupInfo.cb = sizeof(STARTUPINFO);
// tell the application that we are setting the window display
// information within this structure
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
// set the window display to HIDE
StartupInfo.wShowWindow = SW_HIDE;
将隐藏控制台窗口。不过,这对我也不起作用。我有这种感觉,我在这里错过了一个主要概念,所以我需要你们的知识。我想创建一个简单的.exe,比如一个while循环或一个不显示任何东西的简单打印。我错过了什么?