• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Detecting if a process is 16-bit or DOS (Win95B and Win98)

I already know how to enumerate running processes on Windows 95 rev. B and Windows 98 using Process32First() and Process32Next() functions. My problem is that I need to be able to identify if the process is 32-bit (I don't care if it's console or not), 16-bit Windows, or a DOS program. How can I go about doing this?
1 Solution
Have a look at this article.. it has the info on how to determine the application type .

Determine if an Application is Console or GUI


Hope it helps!

Easier methods:

1. The GetProcessVersion function obtains the major and minor version numbers of the system on which a specified process expects to run. Use the th32ProcessID member of the PROCESSENTRY32 structure. The version number returned by this function is the version number stamped in the image header of the .EXE file the process is running. Linker programs set this value.

2. The SHGetFileInfo function with the SHGFI_EXETYPE flag. Use the szExeFile member of the PROCESSENTRY32 structure.
eppsmanAuthor Commented:
Sorry, but I pointed out in my question that I don't care whether or not the process is GUI or console, but I need to find out which processes are DOS based and which ones are old 16-bit apps designed for Windows 3.1. I hope this clarify's everything.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

If uFlags contains the SHGFI_EXETYPE flag, the return value specifies the type of the executable file. It will be one of the following values: Value  Executable File Type
0  Nonexecutable file or an error condition
LOWORD = NE or PE and HIWORD = 3.0, 3.5, or 4.0  Windows application
LOWORD = MZ and HIWORD = 0  MS-DOS .exe, .com, or .bat file
LOWORD = PE and HIWORD = 0  Win32 console application

chensu is right,

here comes some Delphi code:

type TExeType = (etUnknown, etDos, etWin16, etConsole, etWin32);

function ExeType(exefile: string) : TExeType;
var c1  : cardinal;
    sfi : TSHFileInfo;
    s1  : string;
  s1:=chr(c1 and $ff)+chr((c1 and $ff00) shr 8);
  if       s1='MZ'                                                           then result:=etDos
  else if  s1='NE'                                                           then result:=etWin16
  else if (s1='PE') and (hiWord(c1)=0)                                       then result:=etConsole
  else if (s1='PE') and (hiWord(c1)>0)                                       then result:=etWin32
  else if IsTextEqual(upStr(ExtractFileName(exefile)),upStr('winoa386.mod')) then result:=etDos
  else                                                                            result:=etUnknown;

Regards, Madshi.

eppsmanAuthor Commented:
chensu, what header file do I need to #include for SHGetFileInfo()? Also, is this functioin available to all versions of Win95, or do they need IE4 for this function to be present on their system?
#include <shellapi.h>

SHGetFileInfo is supported by Windows 95/NT 4.0 original version and later. See

eppsmanAuthor Commented:
chensu, I'll give you the points, so you may propose SHGetFileInfo() as an answer.
Thanks again.
Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now