From: Ahmed Samieh on

Steve wrote:
> Ahmed Samieh wrote:
> >
> > if you wanna get the file name of any running process by handle you can
> > use this code :
> >
> > GetModuleFileName(GetWindowLong(hWnd, GWL_HINSTANCE),
> > szModuleFileName,
> > sizeof(szModuleFileName));
> >
>
> Have you tried it? It doesn't work. At least, I can't make it work. All
> it returns is the filename to my own exe regardless of what hWnd I give it.

i didn't try it, coz i hvn't win9x, on win2k or xp it will return the
filename of ur exe
test it on win9x
i googled the problem and found this:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q112649
http://www.elists.org/pipermail/delphi-talk/2004-September.txt

Ahmed

From: Alf P. Steinbach on
* Ahmed Samieh:
> Steve wrote:
>> Ahmed Samieh wrote:
>>> if you wanna get the file name of any running process by handle you can
>>> use this code :
>>>
>>> GetModuleFileName(GetWindowLong(hWnd, GWL_HINSTANCE),
>>> szModuleFileName,
>>> sizeof(szModuleFileName));
>>>
>> Have you tried it? It doesn't work. At least, I can't make it work. All
>> it returns is the filename to my own exe regardless of what hWnd I give it.
>
> i didn't try it, coz i hvn't win9x, on win2k or xp it will return the
> filename of ur exe
> test it on win9x
> i googled the problem and found this:

A module handle (what you get from GWL_INSTANCE) is the base address of
a loaded module.

It's only guaranteed to be unique within a process, because each process
has its own address space.

For the main executable it's very likely to be the number 0x00400000 no
matter which process.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: Ahmed Samieh on

Alf P. Steinbach wrote:
> * Ahmed Samieh:
> > Steve wrote:
> >> Ahmed Samieh wrote:
> >>> if you wanna get the file name of any running process by handle you can
> >>> use this code :
> >>>
> >>> GetModuleFileName(GetWindowLong(hWnd, GWL_HINSTANCE),
> >>> szModuleFileName,
> >>> sizeof(szModuleFileName));
> >>>
> >> Have you tried it? It doesn't work. At least, I can't make it work. All
> >> it returns is the filename to my own exe regardless of what hWnd I give it.
> >
> > i didn't try it, coz i hvn't win9x, on win2k or xp it will return the
> > filename of ur exe
> > test it on win9x
> > i googled the problem and found this:
>
> A module handle (what you get from GWL_INSTANCE) is the base address of
> a loaded module.

> It's only guaranteed to be unique within a process, because each process
> has its own address space.

ammmm, it seems to be the best way to make it under win9x is using
ToolHelp32

the problem exist since 11/05/1998 :)
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10095725.html


> For the main executable it's very likely to be the number 0x00400000 no
> matter which process.

not always, sometimes give me 0x01000000, 0x75F80000, .... and
0x00400000 too


Ahmed

First  |  Prev  | 
Pages: 1 2 3 4
Prev: Get Firefox URL?
Next: FindFirstUrlCacheEntry (WinInet)