🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages Started by Emmanuel Sat, 16 Jun 2007 11:32
How Can I get the Program path of a given hWnd
#1770
Author: Emmanuel
Date: Sat, 16 Jun 2007 11:32
8 lines
1071 bytes
Dear All,

If I got a hWnd of an application, How can I know the program file name,and 
where the path of the program,

thank

Emmanuel 
Re: How Can I get the Program path of a given hWnd
#1772
Author: Remy Lebeau (TeamB)
Date: Sat, 16 Jun 2007 15:24
12 lines
1341 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message
news:om1873pd7b693i0j90qr3jpi38komt1j4u@4ax.com...

> See the help section:  Retrieving a Window Property
> http://msdn2.microsoft.com/en-us/library/Aa929345.aspx

That is for Windows CE only.  "PROP_BUFFER" returns NULL data on
Win32.


Gambit
Re: How Can I get the Program path of a given hWnd
#1773
Author: Remy Lebeau (TeamB)
Date: Sat, 16 Jun 2007 15:29
16 lines
1546 bytes
"Emmanuel" <emmanuel@erphk.com> wrote in message
news:4673ca37$1@newsgroups.borland.com...

> If I got a hWnd of an application, How can I know the
> program file name, and where the path of the program,

An HWND does not store that information.  You cannot retreive the
filename directly from an HWND alone.  What you will have to do
instead is use GetWindowThreadProcessId() to get the process ID of the
HWND, and then loop through all of the running processes on the
machine until you find a matching ID.  Then you will know the
filename.


Gambit
Re: How Can I get the Program path of a given hWnd
#1771
Author: Bob Gonder
Date: Sat, 16 Jun 2007 16:21
15 lines
1483 bytes
Emmanuel wrote:

>If I got a hWnd of an application, How can I know the program file name,and 
>where the path of the program,

See the help section:  Retrieving a Window Property
http://msdn2.microsoft.com/en-us/library/Aa929345.aspx

hMemProp = (HGLOBAL) GetProp(hwndSubclass, "PROP_BUFFER"); 
lpFilename = GlobalLock(hMemProp); 
nSize = sprintf(tchBuffer,  "Path to file:  %s", lpFilename); 

I haven't found where the magic strings are listed, but you can enum
them with  EnumPropsEx
http://msdn2.microsoft.com/en-us/library/aa920752.aspx
Re: How Can I get the Program path of a given hWnd
#1774
Author: Bob Gonder
Date: Sun, 17 Jun 2007 13:05
23 lines
1791 bytes
Remy Lebeau (TeamB) wrote:

>> See the help section:  Retrieving a Window Property
>> http://msdn2.microsoft.com/en-us/library/Aa929345.aspx
>
>That is for Windows CE only.  "PROP_BUFFER" returns NULL data on
>Win32.

Good. I didn't like that "solution" anyway.

You didn't mention which function yields " running processes"

Ah! here it is..
SAMPLE: MODLIST.EXE Shows How to Enumerate Processes and Modules
http://support.microsoft.com/kb/192986

CreateToolhelp32Snapshot()
   Process32First()
   Process32Next()

And on the NT lineage (NT,2000,Xp,Vista) there is EnumProcesses 
Example code:
http://msdn2.microsoft.com/en-us/library/ms682623.aspx
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads