Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


To know process(task) type

Posted on 1999-07-25
Medium Priority
Last Modified: 2010-04-04

I can list all processes that currently active using process32first() and process32next() from ToolHelp32 unit but I can't determine process type, i.e. 16-bit or 32-bit.
How to know a process type? Thank you for your help.

Question by:Hencah
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 1391133
I think they are all 32 bit. Eg: The dos boxes are 32 bit applications implementing a 16 bit process space for the DOS apps...


LVL 10

Expert Comment

ID: 1391134
there are some DOS programs that you can run in Windows too, if they don't hang up your system ;)
LVL 10

Expert Comment

ID: 1391135
one way I can think of is to find the main process handle, and from there find the path to the file which has executed the program... then you can use a function to determine whether or not this is a DOS or a WINDOWS program... Alex, has got a great example for doing just that (determining the type of program) on his website at

also check his website at

Good Luck!!

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 20

Accepted Solution

Madshi earned 80 total points
ID: 1391136
Hi guys,

here comes the solution:

type TExeType = (etUnknown, etDos, etWin16, etConsole, etWin32);
function ExeType (exefile: string) : TExeType;
// Determines the type of the executable.

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.

LVL 10

Expert Comment

ID: 1391137
Hello Madshi :))

In fact, Alex's code does exactly that and kinda looks similar.. take a look at it... the real problem is that it is a PROCESS that is currently RUNNING, and you need to get the main process if you have a child process, and from there somehow find the name of the exe, and it is THEN when you use the code I/you suggested... I would say FindExecutable() might help a little in finding the executable...


LVL 20

Expert Comment

ID: 1391138
Hi Viktor,

no, you don't have to look at child/parent processes. In win32 there are no child/parent processes. You can ask which process was started by which process. But it's no real parent/child relationship. Each process is completely on its own.
And why calling FindExecutable? I don't get it.
Cah said, he was using the toolhelp functions. The toolhelp functions give you the full executable path. You can DIRECTLY give it into my function. No problem that it is currently running. I'm doing this all the time...
And you don't need a process handle, either.

Alex code is a bit different. He doesn't use SHGetFileInfo. But why? SHGetFileInfo does a good job, and it works with currently running processes, too. Perhaps you get problems with checking running processes, if you use *HIS* code...  :-))

Regards, Madshi.

Author Comment

ID: 1391139
HI Madshi

I accept your answer, Big thanks


Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA:…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question