code_junkie

Can a Win32 console application detect if it has been run from the explorer or not

Nov 14th, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. if(!GetConsoleTitle(NULL, 0) && GetLastError() = ERROR_SUCCESS {
  2. // Console
  3. } else {
  4. // GUI
  5. }
  6.  
  7. if(AttachConsole(ATTACH_PARENT_PROCESS)=FALSE){
  8. // GUI
  9. } else {
  10. // Console, and you have a handle to the console that already exists.
  11. }
Add Comment
Please, Sign In to add comment