Article View: borland.public.cppbuilder.nativeapi
Article #14131Re: GetModuleFileName problem
From: Remy Lebeau (TeamB)
Date: Thu, 28 Aug 2003 00:45
Date: Thu, 28 Aug 2003 00:45
36 lines
2584 bytes
2584 bytes
"Martin C" <martinc@aol.com> wrote in message
news:3f4d3a81@newsgroups.borland.com...
> well if GetWindowLong is NULL, then why it is returning library
> path for the exe (c:\windows\VCL50.bpl) of the newly create
> program window??
Because global hooks are executed in the context of all running processes
and threads. When you spawn a new process, your hook will be injected into
that process and executed within the context of that new process. Passing
NULL to GetModuleFileName() retreives the filename for the calling process.
If your hook is inside the context of another process at the time of calling
GetModuleFileName() and you are passing NULL, you get the filename of that
process.
> and do you suggest any other solution where I can get exe
> path of the newly created windows ??
Rather than using GetModuleFileName(), you could try using
GetWindowThreadProcessId() instead. Once you have the process ID of the
window, you can then enumerate through all of the currently running
processes until you find a match, at which time you will know the executable
filename as well. For information on enumerating processes, have a look at
this article:
HOWTO: Enumerate Applications Using Win32 APIs
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q175030
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03
Technical Details
Message-ID:
<3f4d508c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!wn14feed!worldnet.att.net!169.207.30.132!newsengine.sol.net!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f4d1e9e@newsgroups.borland.com> <kcaqkv417tdarbqps4v1egl925lc9fgeet@4ax.com> <3f4d3a81@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,a9f30fdc93d98f91 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-27 18:09:29 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f4d1e9e@newsgroups.borland.com> <kcaqkv417tdarbqps4v1egl925lc9fgeet@4ax.com> <3f4d3a81@newsgroups.borland.com> Subject: Re: GetModuleFileName problem Date: Wed, 27 Aug 2003 17:45:06 -0700 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3f4d508c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1062031500 207.175.226.26 (27 Aug 2003 17:45:00 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!wn14feed!worldnet.att.net!169.207.30.132!newsengine.sol.net!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail