472,992 Members | 3,304 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 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 4501
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: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.