Article View: borland.public.cppbuilder.nativeapi
Article #16056Re: obtain the full path and filename for the executable file associated with a given process
From: Vladimir Afanasyev
Date: Mon, 02 Jun 2003 09:49
Date: Mon, 02 Jun 2003 09:49
25 lines
2032 bytes
2032 bytes
Hi Stefano, "Stefano Bonifazi" <stefboombastic@libero.it> wrote: >Hello everybody! > I would like to get the obtain the full path and filename for the >executable file associated with a given process whose identifier I know... >I found this on Borland Help: >"To obtain the full path and filename for the executable file containing the >process code, use the GetModuleFileName function." >Well the first parameter of this function is: >HMODULE hModule, // handle to module to find filename for > >I thought that could be the handle given by the OpenProcess function, but >with that GetModuleFileName always fails... any idea how to get that >hModule? Or if is there another way to get the "process' exe filename" ?? > You can use WMI for this. One from my samples do it: http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=19443 But WMI native only for Win2000/XP. For Win95/98/NT4 you need install WMI Core (from MS site). And no guarantee that WMI class for process existed for WMI Core. Vladimir.
Technical Details
Message-ID:
<3edb1d99$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3edb05ea$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,6b0bea3622ac4fd0 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-02 02:52:04 PST From: "Vladimir Afanasyev" <avv@systema.kiev.ua> Sender: "Vladimir Afanasyev" <avv@systema.kiev.ua> Reply-To: "Vladimir Afanasyev" <avv@systema.kiev.ua> Subject: Re: obtain the full path and filename for the executable file associated with a given process Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 62.244.14.114 62.244.14.114 X-Forwarded-For: 192.168.0.147 References: <3edb05ea$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.65 Message-ID: <3edb1d99$1@newsgroups.borland.com> Date: 2 Jun 2003 02:49:13 -0700 X-Trace: newsgroups.borland.com 1054547353 207.105.83.65 (2 Jun 2003 02:49:13 -0700) Lines: 25 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail