Process ID from filename under VS 6

A co-worker just asked me how to get a Process ID from a filename using Visual Studio 6 under Windows 2000. If it’s not clear, this is not a driver question.

Thanks for any help. I will see if I can find the answer, but if anyone knows the answer please let me know for him.

Paul

Hmmm… Not to be monumentally dense, but how is it exactly that Process ID and Filename are linked?

A file name is a path \windows\system32\notepad.exe

A process is an executing instance of a given application. So there’s not a one to one relationship. It can be one file to many processes or one file to zero processes.

I clearly don’t understand the question,

Peter
OSR
@OSRDrivers

Multiple processes can have the same file open, so there is no 1:1
relationship. You can enumerate all of the handles opened by a process and
backtrack to get the file names of those files.

On the other hand, you may be asking about the executable file itself.

If you clarify, maybe we can be more helpful.

On Tue, Jul 28, 2015 at 5:13 PM, wrote:

> A co-worker just asked me how to get a Process ID from a filename using
> Visual Studio 6 under Windows 2000. If it’s not clear, this is not a driver
> question.
>
> Thanks for any help. I will see if I can find the answer, but if anyone
> knows the answer please let me know for him.
>
> Paul
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


Jamey Kirby
Disrupting the establishment since 1964

This is a personal email account and as such, emails are not subject to
archiving. Nothing else really matters.

I just asked David, my co-worker, some follow up questions.

It is embeddedXP, not 2000. This is on custom hardware on a locomotive somewhere in the world. We work on data gathering for railway customers. We make the locomotive’s black boxes, which are actually orange.

David has written a client which communicates with a server on the same machine via sockets. Every time the client receives a message from the server, he resets a ten second watchdog timer. The traffic between the client & server is heavy. If the watchdog timer asserts, it is fair to say that the server has crashed, restarted and has a new listening socket, which the client is not aware of. The debugger shows that the new server has a new PID. The only thing my co-worker knows about the server is that it is C:\somedir\servername.exe. The customer wants David to look into getting the PID for servername.exe while connected and compare it with the PID for servername.exe after the watchdog timer asserts. If they are different, I am not sure what he plans to do, but he will know that the server crashed and his original connection is lost.

We have no control of the server and no access to source. We can’t tweak the server or have it do anything to help us. We can only communicate via sockets.

David asked me as he was late walking out the door, so I did not get a lot of details last night.

Thanks.
Paul

xxxxx@gmail.com wrote:

David has written a client which communicates with a server on the same machine via sockets. Every time the client receives a message from the server, he resets a ten second watchdog timer. The traffic between the client & server is heavy. If the watchdog timer asserts, it is fair to say that the server has crashed, restarted and has a new listening socket, which the client is not aware of. The debugger shows that the new server has a new PID. The only thing my co-worker knows about the server is that it is C:\somedir\servername.exe. The customer wants David to look into getting the PID for servername.exe while connected and compare it with the PID for servername.exe after the watchdog timer asserts. If they are different, I am not sure what he plans to do, but he will know that the server crashed and his original connection is lost.

Seems to me that the right way to do that is to use the Service Control
Manager. Use OpenService and NotifyServiceStatusChange, and you’ll get
called every time the service goes up and down.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks, Tim. That sounds like a great way to do it. I’m passing along your comments to David.
Paul