For Programmers: Free Programming Magazines  


Home > Archive > VC Language > June 2005 > Console App - howto determine if an app is a console app









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Console App - howto determine if an app is a console app
tendengarci@yahoo.com

2005-06-02, 9:06 am

How can I find out if an application is a console app or a windows app.
I realize that if there the header starts with 0xd4 0x5a it cannot be
run in "DOS" mode but that not mean a Windows 2000 console app. I have
win2k console apps and they also start with 0x4d 0x5a.

thanks for the help


john

Igor Tandetnik

2005-06-02, 4:01 pm

<tendengarci@yahoo.com> wrote in message
news:1117711356.717282.298980@g49g2000cwa.googlegroups.com
> How can I find out if an application is a console app or a windows
> app. I realize that if there the header starts with 0xd4 0x5a it
> cannot be run in "DOS" mode but that not mean a Windows 2000 console
> app. I have win2k console apps and they also start with 0x4d 0x5a.


The PE (Portable Executable) file format is described here:

http://msdn.microsoft.com/library/e...n_peeringpe.asp

You need to look at IMAGE_OPTIONAL_HEADER::Subsystem field.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Jochen Kalmbach [MVP]

2005-06-02, 4:01 pm

Hi tendengarci!
> How can I find out if an application is a console app or a windows app.
> I realize that if there the header starts with 0xd4 0x5a it cannot be
> run in "DOS" mode but that not mean a Windows 2000 console app. I have
> win2k console apps and they also start with 0x4d 0x5a.


The offical way is to use the "ImageNtHeader" function and look into the
"IMAGE_NT_HEADERS" and here into "IMAGE_OPTIONAL_HEADER" and then
check the "Subsystem" value (IMAGE_SUBSYSTEM_WINDOWS_CUI).

See: ImageNtHeader
http://msdn.microsoft.com/library/e...agentheader.asp

See: IMAGE_NT_HEADERS
http://msdn.microsoft.com/library/e...headers_str.asp

See: IMAGE_OPTIONAL_HEADER
http://msdn.microsoft.com/library/e..._header_str.asp

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jochen Kalmbach [MVP]

2005-06-02, 4:01 pm

Hi Igor!
> The PE (Portable Executable) file format is described here:
> http://msdn.microsoft.com/library/e...n_peeringpe.asp


And the (latest) specification is here:
http://www.microsoft.com/whdc/syste...are/PECOFF.mspx


--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Alex Blekhman

2005-06-02, 4:01 pm

tendengarci@yahoo.com wrote:
> How can I find out if an application is a console app or
> a windows app.


KB90493 - "HOWTO: How To Determine Whether an Application is
Console or GUI"
http://support.microsoft.com/defaul...=kb;en-us;90493


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com