Solved

Get ProcessID from Module Name

Posted on 1998-09-30
13
453 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
[X]
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
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create cascading comboboxes so combox 2 shows just related fields from combobox 1 11 20
Event ID 10010 3 77
What are the big features of MVC5? 4 95
windbg taking it's time 32 100
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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