Page 1 of 1

Console or GUI application??

Posted: Fri Jan 16, 2004 12:15 pm
by Seldon
Can I see from a DLL of mine if the calling program is a CONSOLE or WINGUI application ? Thanks for any hints.

Posted: Fri Jan 16, 2004 12:48 pm
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
----

Posted: Fri Jan 16, 2004 2:19 pm
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.