🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14178

Window thread problem

#14178
From: Martin C
Date: Wed, 03 Sep 2003 12:29
34 lines
2312 bytes
Hi all,

I am trying to make CBT hook using HSHELL_WINDOWCREATED to get notified once
a new window is being created, to retrieve the window handle and the (exe
name) that initiated this window, although every time I try to run Internet
Explorer (as an example) I receive (BROWSEUI.dll) as the exe that initiated
this window, I don't know how to get (iexplorer.exe) instead of
(BROWSEUI.dll).

I use the following code sequence:

//Get the handle of the newly created window
HWND hwndToNewWindow = (HWND)wParam;

// Get the windows title
if(hwndToNewWindow != NULL) { GetWindowText(hwndToNewWindow, title, 256); }

//Get the full path of the exe that initiated the window
GetModuleFileName(((HMODULE)GetWindowLong(hwndToNewWindow,
GWL_HINSTANCE)),buff,sizeof(buff));

//Get the process ID of the Application that created this window
TheParentWindowProcessID=GetWindowThreadProcessId(hwndToNewWindow, NULL);

//Then compare the (TheParentWindowProcessID) with all running windows
process using (CreateToolhelp32Snapshot) function and start comparing
(Proc.th32ProcessID) with the (TheParentWindowProcessID)

and after all of this I still get BROWSEUI.dll as the exe that created this
window !, so can someone tell me please what I am doing wrong here...

I am developing using BCB5 under Windows XP

thanks
Technical Details
Message-ID: <3f55de92@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e603364ec1c07f71,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-09-03 05:40:46 PST
From: "Martin C" <martinc@aol.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Window thread problem
Date: Wed, 3 Sep 2003 04:29:06 -0800
Lines: 36
Organization: V Safe
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.1165
NNTP-Posting-Host: 62.135.27.248
Message-ID: <3f55de92@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1062592146 62.135.27.248 (3 Sep 2003 05:29:06 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail