(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
07-01-24 12:34 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - GetWindowModuleFileName just doesn't work
  
User name:
Password:
Reply:
 
Options: - -
Quik-Attach:
Preview for more options

Max size 1.00 MB, types: png, gif, jpg, txt, zip, rar, tar, gz, 7z, ace, mp3, ogg, mid, ips, bz2, lzh, psd

UserPost
HyperHacker
Posts: 686/5072
Don't see why not.

CurrentWindow.hWnd = GetForegroundWindow();
CurrentWindow.Parent = (HWND)GetParent(CurrentWindow.hWnd);
GetWindowRect(CurrentWindow.hWnd,&CurrentWindow.Pos);
GetClientRect(CurrentWindow.hWnd,&CurrentWindow.ClientArea);
GetText(CurrentWindow.hWnd,CurrentWindow.Title,sizeof(CurrentWindow.Title));
if(!strlen(CurrentWindow.Title))
strcpy(CurrentWindow.Title,"<No Title>");

RealGetWindowClass(CurrentWindow.hWnd,CurrentWindow.Class,sizeof(CurrentWindow.Class));
CurrentWindow.Style = GetWindowLong(CurrentWindow.hWnd,GWL_STYLE);
CurrentWindow.ExStyle = GetWindowLong(CurrentWindow.hWnd,GWL_EXSTYLE);
CurrentWindow.MessageProc = GetWindowLong(CurrentWindow.hWnd,DWL_DLGPROC);
if(!CurrentWindow.MessageProc)
CurrentWindow.MessageProc = GetWindowLong(CurrentWindow.hWnd,GWL_WNDPROC);

CurrentWindow.hInst = GetWindowLong(CurrentWindow.hWnd,GWL_HINSTANCE);
CurrentWindow.ID = GetWindowLong(CurrentWindow.hWnd,GWL_ID);
CurrentWindow.ThreadID = GetWindowThreadProcessId(CurrentWindow.hWnd,&CurrentWindow.ProcID);

CurrentWindow.ModuleName = CurrentWindow.Module;
strcpy(CurrentWindow.Module,"???");
GetWindowModuleFileName(CurrentWindow.hWnd,CurrentWindow.Module,sizeof(CurrentWindow.Module));
for(i=strlen(CurrentWindow.Module);i>=0;i--)
{
if(CurrentWindow.Module[i] == '\\')
{
CurrentWindow.Module[i] = 0;
CurrentWindow.ModuleName = CurrentWindow.Module + i + 1;
break;
}
}
Vertex
Posts: 4/4
Could you post the code you are using to get the hWnd and process module filename?
HyperHacker
Posts: 679/5072
It has to be valid, because passing the same hWnd to other functions gives correct results, and it's not the Unicode version. The function actually returns 0, as in 0 characters copied, or returns the name of the program that called it.
Vertex
Posts: 1/4
Are you absolutely sure that you are providing a valid hWnd? And if you're using the unicode version of GWMFN() then are you sure it's not returning a unicode string and your program is trying to interpret it as ANSI?
HyperHacker
Posts: 671/5072
I can't seem to figure out why but for some reason, GetWindowModuleFileName() just doesn't seem to work. I pass it one window's handle, and it returns the module of another or nothing at all. The desktop window returns shell32.dll which is correct, but the taskbar, created by the same process, returns nothing. Notepad and Calculator return nothing, and Winamp and Console (command prompt frontend) return the name of the program calling it!
Acmlm's Board - I3 Archive - Programming - GetWindowModuleFileName just doesn't work


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.010 seconds; used 346.74 kB (max 384.49 kB)