471,339 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,339 software developers and data experts.

How to determine console or winform app?

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)
Jun 27 '08 #1
6 4286
On May 11, 4:43*pm, "None" <n...@none.comwrote:
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)
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
Jun 27 '08 #2
"None" <no**@none.comwrote:
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)
You will need to study the Portable Executable (PE) file format.
http://www.microsoft.com/whdc/system...re/PECOFF.mspx
Then you can open the .exe file with a BinaryReader and pick out the
information you need.

Eq.
Jun 27 '08 #3
On Sun, 11 May 2008 06:43:31 -0700, None <no**@none.comwrote:
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)
One way would be to use the "Debug Help" library
(http://msdn.microsoft.com/en-us/libr...9(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
Jun 27 '08 #4
thanks. I am looking into the pe file format.
"Paul E Collins" <fi******************@CL4.orgwrote in message
news:qb*********************@bt.com...
"None" <no**@none.comwrote:
>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)

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

Eq.


Jun 27 '08 #5
In article <op***************@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

Jun 27 '08 #6
On Wed, 14 May 2008 03:51:04 -0700, Mike Blake-Knox
<mi****@community.nospamwrote:
In article <op***************@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.
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
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Ron Vecchi | last post: by
2 posts views Thread by Steve | last post: by
5 posts views Thread by Scott | last post: by
2 posts views Thread by RobcPettit | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.