Update: On Windows NT however you can see if the application is called from a console window or the GUI.
Code:
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
LPWSTR *szArglist;
int nArgs;
int i;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if (szArglist != NULL)
{
for (i=0; i<nArgs; i++) {
if (szArglist[i] == "WIN") {
print("We have a gui\n");
LocalFree(szArglist);
return 0;
}
}
}
print("We have a console\n");
// Free memory allocated for CommandLineToArgvW arguments.
LocalFree(szArglist);
return 0;
}