Prev: Get Firefox URL?
Next: FindFirstUrlCacheEntry (WinInet)
From: Alf P. Steinbach on 12 May 2006 18:45 * Steve: > Alf P. Steinbach wrote: >> * Steve: >>> Alf P. Steinbach wrote: >>>> >>>> Is it a filename for the executable for the window's process? >>>> >>>> Then I suggest follow Olof Lagerkvist's advice in this thread, >>>> namely using the ToolHelp API. One way could be (1) >>>> GetWindowThreadProcessId, (2) CreateToolhelp32Snapshot, (3) >>>> Module32First. And if that sometimes happens to find a module other >>>> than the original executable, also retrieve the module handle in >>>> step 1, using GetWindowLongPtr, and use a loop checking for that >>>> module handle in step 3. >>>> >>>> There may be some easier and/or more efficient way, I don't know. >>>> >>> >>> So what are you saying then? You don't know? Then why answer? >> >> You've been given a step by step cookbok recipe. >> >> You'll have to translate that cookbook recipe into working code yourself. >> >> At least make an attempt. >> >> > No Alf. You've managed to take a snippet of your post to make me look > stupid, Can't comment on your feelings of stupidity, but rest assured that making you feel that way has not been my intention: this is a technical group, and getting technical inaccuracies or errors corrected is much of the point of posting questions here. Furthermore, since it became clear to me that you felt that way about being corrected I stopped correcting you. And unlike you I haven't searched for other postings of yours to try to mock: the game you're referring to is being played by only you. It's an error to read more into technical corrections. If you don't want to learn, don't post, it's that simple. [snip] > If you don't know or don't have an answer, they don't post. See the quoted material above for one answer, laid out 1-2-3; see else-thread for other answers, including code. -- 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: Steve on 13 May 2006 11:47 I thought you weren't talking to me anymore? Or do you just like to get the last word in?
From: Ahmed Samieh on 16 May 2006 05:54 Steve wrote: > There is an API called GetModuleFileNameEx which can retrieve a filename > from a process ID which can in turn be retrieved from a HWND. > GetModuleFileNameEx is for NT based machines, so for Windows 95/98/Me, I > need to use GetModuleFileName. But this version requires a module handle > , and it seems to get a module handle using GetModuleHandle which > requires a filename (!?). So, how do I retrieve a filename from a HWND > in Windows 98? HMODULE GetModuleHandle( LPCTSTR lpModuleName // address of module name to return handle for ); lpModuleName If this parameter is NULL, GetModuleHandle returns a handle of the file used to create the calling process. Return Value If the function succeeds, the return value is a handle to the specified module. DWORD GetModuleFileName( HMODULE hModule, // handle to module to find filename for LPTSTR lpFilename, // pointer to buffer for module path DWORD nSize // size of buffer, in characters ); Parameters hModule Identifies the module whose executable filename is being requested. If this parameter is NULL, GetModuleFileName returns the path for the file used to create the calling process. lpFilename Points to a buffer that is filled in with the path and filename of the given module. nSize Specifies the length, in characters, of the lpFilename buffer. If the length of the path and filename exceeds this limit, the string is truncated. so you can use this code : char szModuleFileName[256] = {0}; GetModuleFileName(GetModuleHandle(NULL), szModuleFileName, sizeof(szModuleFileName));
From: Ahmed Samieh on 16 May 2006 06:46 Ahmed Samieh wrote: > DWORD GetModuleFileName( > > HMODULE hModule, // handle to module to find filename for > LPTSTR lpFilename, // pointer to buffer for module path > DWORD nSize // size of buffer, in characters > ); > Parameters > > hModule > > Identifies the module whose executable filename is being requested. If > this parameter is NULL, GetModuleFileName returns the path for the file > used to create the calling process. > so you can use this code : > > char szModuleFileName[256] = {0}; > GetModuleFileName(GetModuleHandle(NULL), > szModuleFileName, > sizeof(szModuleFileName)); or this one char szModuleFileName[256] = {0}; GetModuleFileName(NULL, szModuleFileName, sizeof(szModuleFileName)); that's done if you wanna get the file name of your executable file - the caller process 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));
From: Steve on 19 May 2006 03:48 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.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Get Firefox URL? Next: FindFirstUrlCacheEntry (WinInet) |