Solved

Get ProcessID from Module Name

Posted on 1998-09-30
13
436 Views
Last Modified: 2013-12-03
I use CreateProcess to start InstallShield setup.exe - but the setup.exe immediately starts _isdel.exe and terminates. I can't use WaitForSingleObject on setup.exe process ID because it terminates right away.

I need to get a ProcessID for _isdel.exe - but I can't find anyway to do this. OpenProcess seems only designed to get the current ProcessID.

I want to avoid ToolHelp stuff cuz I need a 95/NT solution (and this is too small a task for me to warrent two coding solutions per platform).

(Anyone know of any documentation that lists each Windows object (handle, module, etc.) and shows all paths from here to there? (e.g. I've got X and need Y - how do I get there?))
0
Comment
Question by:chrismo
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1414926
chrismo,

well, I know it's not what you wanted...

You could determine which operating system is running (GetVersionEx) and then use either toolhelp functions (win95/win98/winNT5) or "psApi.dll" stuff (winNT4) to enumerate all running processes.

Regards, Madshi.
0
 
LVL 2

Expert Comment

by:lucidity
ID: 1414927
http://www.geocities.com/ResearchTriangle/Lab/5376/Spells/TMan/index.html

The above link is source for a Process ID enumerator, It stores the ID in a structure along with the .EXE name. So if you match the .EXE name you can get the PID and whamo, do what ever you want with it, or just wait until its done.
0
 

Author Comment

by:chrismo
ID: 1414928
(a) I'm coding in Delphi (sorry I forgot to mention) - so I can't use any C++ code. I can do the translation - but ...
(b) I need the details - not a reference to a site that has some source code that's dependent on other source code that I've got to download and wade through. I appreciate the links - they're better than nothing - but, to me, they hardly qualify as an answer. Especially if digging through source code to the Platform SDK's source code merely yields ToolHelp(95)/PSAPI(NT) calls at root, which is what I suspect is going on with the source you've referred me to.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1414929
When calling 'CreateProcess', the system fills in a PROCESS_INFO structure which holds a member named 'dwProcessId' - i think that's what you need...
0
 

Author Comment

by:chrismo
ID: 1414930
Sorry. In my case I stated in my question - I use CreateProcess to start Setup.exe - Setup.exe then creates another process (_isdel.exe) and shuts down.

I need my app to wait until _isdel.exe is finished. But - I don't have its process ID - how do I get it? I cannot use Toolhelp / PSAPI (for my own reasons) ...
0
 
LVL 86

Expert Comment

by:jkr
ID: 1414931
Well, if you weren't using Delphi, i'd have suggested taking a look at the sources of the 'Process Viewer' that's shipped with VC++...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 1414932
Ooops ....
If all you have to do is wait for the termination of _isdel.exe, i'd suggest a totally different approach: As _isdel.exe is the deleter process for the temporary installation files (and usually deletes itself, use 'FindFirst/NextChangeNotification()' to get notified about the changes. Then, check whether _isdel.exe is still present and continue waiting until it is deleted.
0
 

Author Comment

by:chrismo
ID: 1414933
So ... use FindFirst with FILE_NOTIFY_CHANGE_FILE_NAME on _isdel.exe and wait until it's deleted, eh? Not a bad idea. That'd probably work.

Well - not exactly what I was looking for - but does what I need - what the hey.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1414934
Ooops, it won't be that easy i think, but you got the idea ;-)
The problem is when 2 installation programs are running simultaneously (just imagine another one is started to install e.g. a database engine), you'll have to keep track of what's going on...
0
 

Author Comment

by:chrismo
ID: 1414935
True enough - but I'll handle that if and when I come to it. Thanks for the input...

BTW, is there *anyway* to do what I originally asked for other than use Toolhelp? Or is the answer "Duh - use Toolhelp, that's exactly why it's there...")?
0
 
LVL 86

Expert Comment

by:jkr
ID: 1414936
Well, i actually don't know 'Toolhelp' (prefer to use NT), but there are some undocumented NT kernel routines to do this ('NtQuerySystemInformation()'). An other possibility would have been to scan the PID range using 'OpenProcess()' in conjunction with 'ReadProcessMemory()' (heavy & crude) or the symbol functions of imagehlp.dll.
0
 

Author Comment

by:chrismo
ID: 1414937
Hmmm ... OK - thanks for the help.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1414938
chrismo,

with NT you can use the PsApi.Dll to enumerate all process IDs. It is documented!

Regards, Madshi.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now