Click here to Skip to main content
11,573,408 members (55,207 online)
Click here to Skip to main content

Tagged as

How to find whether the parent process is GUI or Console

, 10 Apr 2009 CPOL 29K 5
Rate this:
Please Sign up or sign in to vote.
This is not 100% fool proof. How ever in normal cases, this works great. This technique can be used to find out, whether the child application was launched from a GUI application or from a Console application.if( AttachConsole( ATTACH_PARENT_PROCESS )){ AfxMessageBox( _T("Parent process is a con

This is not 100% fool proof. How ever in normal cases, this works great. This technique can be used to find out, whether the child application was launched from a GUI application or from a Console application.

if( AttachConsole( ATTACH_PARENT_PROCESS ))
{
     AfxMessageBox( _T("Parent process is a console application"));
}
else
{
     AfxMessageBox( _T("Parent process is not a console application"));
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Naveen
Software Developer (Senior)
Singapore Singapore
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 1 Pin
aphazel 死神12-Jan-10 2:37
member aphazel 死神12-Jan-10 2:37 
GeneralMy vote of 1 Pin
Blkbam9-Apr-09 5:10
memberBlkbam9-Apr-09 5:10 
GeneralRe: My vote of 1 Pin
Naveen10-Apr-09 5:19
mvpNaveen10-Apr-09 5:19 
AnswerThe C# way Pin
Blkbam9-Apr-09 5:08
memberBlkbam9-Apr-09 5:08 
GeneralRe: The C# way Pin
Qistoph9-Apr-09 20:09
memberQistoph9-Apr-09 20:09 
GeneralRe: The C# way Pin
Naveen10-Apr-09 5:22
mvpNaveen10-Apr-09 5:22 
GeneralMy vote of 1 Pin
Qistoph8-Apr-09 22:41
memberQistoph8-Apr-09 22:41 
GeneralRe: My vote of 1 Pin
Naveen10-Apr-09 5:18
mvpNaveen10-Apr-09 5:18 
GeneralRe: My vote of 1 Pin
toxcct27-Apr-09 2:48
mvptoxcct27-Apr-09 2:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150624.2 | Last Updated 10 Apr 2009
Article Copyright 2009 by Naveen
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid