Mein Luck
Mein Luck

Reputation: 47

How to tell if a windows PE file is a console subsystem or a windows subsystem programmatically?

Basically I need a program that will sort windows .exe's from the console counterparts.

A file scanner:

SortExe(file exe) 
{
 if (IsPeWindows(exe)) 
    {
      AddToList1(exe); 
    }
 else if (IsPeConsole())
    {
    AddToList2(exe); 
    }
 }

How do I implement IsPeWindows or IsPeConsole() ?

I do not particularly mind what language solutions come in so long as it's one of c, c++, c# or visual basic.

Upvotes: 2

Views: 1041

Answers (1)

Alex K.
Alex K.

Reputation: 175826

Pass SHGFI_EXETYPE to SHGetFileInfo() & examine the hi/loword of the return value as explained in the link.

Upvotes: 5

Related Questions