473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 4552
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ron Vecchi | last post by:
I am looking for a way to write xml data to file from a macromedia flash executable. I was thinking about haveing flash call a console app with a parameter...which is the xml string to write to...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
2
by: Steve | last post by:
I have created a console app that simply prints out a message a couple times, then exits, here is the code: <code> for(int i = 0; i < 10; i++) { System.Threading.Thread.Sleep(500);...
5
by: Scott | last post by:
Hi everyone, I have a c# console app that when run through an autorun.inf file, launches a web page from the CD. It works just fine but I would like the console window minimized on startup....
2
by: RobcPettit | last post by:
Hi, This is probably a mute point, but id like to know when to choose a console application to a windows application. What i meen is this. Most coding in books is with the console application. I...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, What is the way to determine what control the mouse is over on a form? Like if the mouse is over a button you could note this in the form's MouseMove Event '--pseudocode here...
6
by: joey.powell | last post by:
I have a windows form app in C# in VS2005. In the "program.cs" file, I take some command line arguments and use "Console.WriteLine("fsdfsd") to give feedback to users. When I step through the...
1
by: ffimbel | last post by:
Hi I would like to implement a single exe which could be invoked either as a standard windows form (no argument) or as a console app (when run with app.exe -nologo). I tried compiling the exe...
5
by: paul korosi | last post by:
Hi, I've got a wcf service that is hosted on my local machine. I need to determine the hosted url of the service from within the service but cannot work out how to do it. HttpContext.Current...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.