Console or GUI application??

Just starting out? Need help? Post your questions and find answers here.
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Console or GUI application??

Post by Seldon »

Can I see from a DLL of mine if the calling program is a CONSOLE or WINGUI application ? Thanks for any hints.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

i asked the same once. Only about window qestion and i got a try. i havent
tryed it yet. But try programming the function openwindow() or something into the dll, and execute the function from another program of yours.
If you try, i would like to hear the result! :D

The reason i havent tryed was time and i havent touch a dll before. Maybe used one, but newer made one..


^^
O
----
Wayne Diamond
User
User
Posts: 38
Joined: Tue Dec 30, 2003 1:37 pm
Location: Australia

Post by Wayne Diamond »

Seldon,
The first part of your challenge is finding out your owner ... this is easily achieved in all Windows OS's from 95 up by the toolhelp api.
In particular, look at PROCESSENTRY32 ... it has a value th32ParentProcessID, so you can check that to find your owner process.

Now that you've found your parent process you can just check its Characteristics flag in the PE header from its file to check if its a console, gui etc, OR, you might prefer to enumerate all windows and check each windows process ID against your parent process ID, and then check if it's "Command Prompt" etc.
Post Reply