Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to determine console or winform app?

1 view
Skip to first unread message

None

unread,
May 11, 2008, 9:43:31 AM5/11/08
to
Hello, my app is written in C#. Given an app file path (e.g. e:\abc.exe),
how can I determine if it's a winform app or a console one. (note: abc.exe
can be either a native exe or a .net one)


kimiraikkonen

unread,
May 11, 2008, 1:00:46 PM5/11/08
to

Hi,
Try to run the application from command prompt (cmd.exe) then if it's
a winform application the application's main form is opened as window,
if not, the program is started and output is visible inside command
prompt as just a guess to verify, better ideas may exist.

Thanks,

Onur Güzel

Paul E Collins

unread,
May 11, 2008, 5:04:10 PM5/11/08
to
"None" <no...@none.com> wrote:

You will need to study the Portable Executable (PE) file format.
http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx
Then you can open the .exe file with a BinaryReader and pick out the
information you need.

Eq.


Peter Duniho

unread,
May 11, 2008, 7:33:01 PM5/11/08
to

One way would be to use the "Debug Help" library
(http://msdn.microsoft.com/en-us/library/ms679309(VS.85).aspx). You can
use the ImageNtHeader() function to retrieve the PE headers for the
executable, and then check the subsystem information to see whether it's
GUI or command-line.

Note that a console application can in fact create a GUI. It's not really
clear why you're trying to do this, but keep in mind that you may or may
not be able to reliably accomplish your goal, depending on what
applications you're dealing with and why you really want to know whether
they are console or GUI.

Pete

None

unread,
May 12, 2008, 11:36:29 AM5/12/08
to
thanks. I am looking into the pe file format.


"Paul E Collins" <find_my_re...@CL4.org> wrote in message
news:qbSdnYbjK9r...@bt.com...

Mike Blake-Knox

unread,
May 14, 2008, 6:51:04 AM5/14/08
to
In article <op.ua0jp...@petes-computer.local>, Peter Duniho
wrote:

> Note that a console application can in fact create a GUI.

Which means a specific executable can be BOTH a console application and
a GUI application.

Mike

Peter Duniho

unread,
May 14, 2008, 1:21:12 PM5/14/08
to

Well, that all depends on your definition of "GUI application". That's
true from a behavioral point of view, but it's not true from a PE
configuration point of view.

We don't have any information from the OP that would help us understand
why he wants this information at all, never mind which is the more
appropriate definition. :)

Pete

0 new messages