View Single Post
Old 03-05-2006, 05:33 PM   #4 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 704
DJMaze is on a distinguished road
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;
}
DJMaze is offline   Reply With Quote