Ali Imran
July 30th, 2005, 11:07 PM
Can we detect if the console window is available ? Means if the program was compiled including console window.
any help is highly appreciated.
regards
any help is highly appreciated.
regards
|
Click to See Complete Forum and Search --> : Detecting if console window is available, how ? Ali Imran July 30th, 2005, 11:07 PM Can we detect if the console window is available ? Means if the program was compiled including console window. any help is highly appreciated. regards golanshahar July 31st, 2005, 02:05 AM i am not sure if this is what you need but you can check the ::GetConsoleWindow(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getconsolewindow.asp) api, if there is one associated with you process it will retun a valid handle else will return NULL. Cheers SuperKoko July 31st, 2005, 06:04 AM You may want different things (but you requested for the point 3). If you need a console window to output informations, you can use AllocConsole. It creates a console if a console does not exists, and does nothing if a console already exists for the process. It works for GUI applications, and console applications created with the DETACHED_PROCESS argument of CreateProcess. If you need to detect if there is a console window currently visible to the user which may have been created at runtime by AllocConsole, or created at startup time because the application is a console application, you should use GetConsoleWindow as golanshahar said. But if you need compatibility with Windows 95/98/Me/NT4 you should not use this function. If you need to detect if the application's executable was compiled as a console application, you should retrieve the executable's file name, with GetModuleFileName on the handle returned by GetModuleHandle(NULL), and then use SHGetFileInfo with uFlags==SHGFI_EXETYPE. And finally you should compare the return value to 0x00004550 (HIWORD==0, LOWORD=PE). You can get informations on MSDN. good luck! :) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |