?
Solved

Get ProcessID from Module Name

Posted on 1998-09-30
13
Medium Priority
?
471 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

765 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