Discussion:
Process Name
(too old to reply)
jjoohhnn
2009-09-01 13:25:19 UTC
Permalink
Hi all,

How to get the process name by using process id?

Thanks in advance.

Regards,
jjoohhnn.
Igor Tandetnik
2009-09-01 16:23:29 UTC
Permalink
Post by jjoohhnn
How to get the process name by using process id?
By process name, do you mean mean the name of the EXE file used to start
the process? OpenProcess followed by GetModuleFileNameEx.

Alternatively, enumerate all processes with Process32First /
Process32Next. You get PROCESSENTRY32 structure for each process which,
among other things, contains the process ID and the EXE name. Look for
an entry matching your ID.
--
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
jjoohhnn
2009-09-02 05:44:32 UTC
Permalink
Igor,

Thank you. It's solved by using OpenProcess and GetModuleFileNameEx
API's.

What is the difference between Process and EXE file?

Regards,
jjoohhnn.
Post by Igor Tandetnik
Post by jjoohhnn
How to get the process name by using process id?
By process name, do you mean mean the name of the EXE file used to start
the process? OpenProcess followed by GetModuleFileNameEx.
Alternatively, enumerate all processes with Process32First /
Process32Next. You get PROCESSENTRY32 structure for each process which,
among other things, contains the process ID and the EXE name. Look for an
entry matching your ID.
--
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
Igor Tandetnik
2009-09-02 11:43:20 UTC
Permalink
Post by jjoohhnn
What is the difference between Process and EXE file?
There are many more EXE files on your hard drive than there are
processes running at any given time. On the other hand, there may be two
or more processes running off the same EXE file at the same time.
--
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
Martin T.
2009-09-02 14:16:18 UTC
Permalink
Post by Igor Tandetnik
Post by jjoohhnn
What is the difference between Process and EXE file?
There are many more EXE files on your hard drive than there are
processes running at any given time. On the other hand, there may be two
or more processes running off the same EXE file at the same time.
Plus - not every process image file needs to be an exe file.
CreateProcess will happily execute every file, regardless of it's extension.

br,
Martin
xiaosi
2009-09-03 14:39:59 UTC
Permalink
Windows system maps the EXE file (on disk) to memory (process address).
Post by jjoohhnn
What is the difference between Process and EXE file?
Loading...