Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alternate to getmodulebasenameA

Status
Not open for further replies.

ADoozer

Programmer
Dec 15, 2002
3,487
AU
this is more of an API question.. but im going to try anyway.

currently using "EnumProcesses", "EnumProcessModules" and "GetModuleBaseNameA" from psapi.dll to look for specific running programs.

however this has a negative side in that if you change the EXE name, the module base name changes.

is there any way to determine what process is running without using its base name?

i cant find anything in msdn (because im not realy sure what im looking for)

any hints greatly appreciated

If somethings hard to do, its not worth doing - Homer Simpson
 
Dunno whether this is of any help. Assuming you are using an OS with WMI installed, add a reference to the Microsoft WMI Scripting Library, then something like the following will list your processes ...
Code:
[blue]    Dim objProcesses As SWbemObjectSet
    Dim objProcess As SWbemObject
    
    Set objProcesses = GetObject("Winmgmts:").ExecQuery("Select * from Win32_Process")
    For Each objProcess In objProcesses
       Debug.Print objProcess.Name, objProcess.ExecutablePath
    Next[/blue]
 
what references will i need for that (i have 2 WMI related references but both kick up a UDT not defined error [win2k pro])

If somethings hard to do, its not worth doing - Homer Simpson
 
doh... its been a hard day..

"Microsoft WMI Scripting Library"

If somethings hard to do, its not worth doing - Homer Simpson
 
nope... that suffers the same fate.

if the exe is renamed the name changes.

If somethings hard to do, its not worth doing - Homer Simpson
 
I'm not sure exactly what it is that you are trying to achieve. Are you suggesting that you somehow want to access the original filename of an excutable/module?

In which case isn't what you need the 'Original File Name" property under that you get under Version in Explorer. Which you should be able to pull if you've got the full path to the executable (as you do with the example code). There's probably a WMI call to get it, but I don't know what it is off hand, so you might like to look at the GetFileVersionInfo API call which, in combination with VerQueryValue will let you get at

Comments InternalName ProductName
CompanyName LegalCopyright ProductVersion
FileDescription LegalTrademarks PrivateBuild
FileVersion OriginalFilename SpecialBuild
 
ok will look into that in the morning.

what im trying to do is (through code) shut down 3 programs that "might" be running.

i have working code for this already, however as ive mentioned changing the exe name defeats this.

i have access to all the programs (including there earlier releases) and i need a method to hard code the programs into a search (if that makes sense)

so, my program loads, checks for the 3 programs in question, shuts them down if they are running. repeat every minute.

If somethings hard to do, its not worth doing - Homer Simpson
 
Right, then it looks like you need OriginalFilename from the GetFileVersionInfo call ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top