Solved

Get ProcessID from Module Name

Posted on 1998-09-30
13
429 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

16 Experts available now in Live!

Get 1:1 Help Now