ibferoz
asked on
How to get process id from window handle?
I have code like following
BOOL CMainFrame::PreTranslateMe ssage(MSG* pMsg){
LPARAM m_winHandle= pMsg->lParam;
...
...
So I have window handle now. From here How can I get process id of the application. Thru which I have to get
application(.EXE's) name.
When I am using the GetWindowModuleFileName as follows for the same purpose its giving me 'undeclared identifier' error.
GetWindowModuleFileName(pM sg->hwnd,f ileBuff,25 6);
Hope my doubt made sence to you.
BOOL CMainFrame::PreTranslateMe
LPARAM m_winHandle= pMsg->lParam;
...
...
So I have window handle now. From here How can I get process id of the application. Thru which I have to get
application(.EXE's) name.
When I am using the GetWindowModuleFileName as follows for the same purpose its giving me 'undeclared identifier' error.
GetWindowModuleFileName(pM
Hope my doubt made sence to you.
This sounds like a compile-time error which tells you that you are attempting to use an identifier that is unknown to the compiler in this context. Since this is an MFC-application, GetWindowModuleFileName is definately known. pMsg, if it is a MSG*, does have a hwnd member. So if this function call is inside your PreTranslateMessage, I'd say you haven't declared fileBuff, or possibly misspelled it.
ASKER
Hi fl0yd ,
Ya its a compile time error and its a MFC application too.
I have checked with all variations. Here I am giving the code and error...
LPTSTR fileBuff[256];
GetWindowModuleFileName(pM sg->hwnd,f ileBuff,25 6);
....
error C2065: 'GetWindowModuleFileName' : undeclared identifier.
Hope you can relate now.
Ya its a compile time error and its a MFC application too.
I have checked with all variations. Here I am giving the code and error...
LPTSTR fileBuff[256];
GetWindowModuleFileName(pM
....
error C2065: 'GetWindowModuleFileName' : undeclared identifier.
Hope you can relate now.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmmmm, strange, I thought MFC #include'd <windows.h> automatically. Try putting this statement
#include <windows.h>
right after the #include "stdafx.h" statement in your implementation file. I'm not sure if you will get compiler errors when doing this.
Somewhat unrelated to your question: you might want to also check out GetModuleFileName( NULL, fileBuff, 256 ) -- which pretty much does the same but is a bit more direct.
#include <windows.h>
right after the #include "stdafx.h" statement in your implementation file. I'm not sure if you will get compiler errors when doing this.
Somewhat unrelated to your question: you might want to also check out GetModuleFileName( NULL, fileBuff, 256 ) -- which pretty much does the same but is a bit more direct.
you should include
#include <WINABLE.H>
TCHAR fileBuff[256];
GetWindowModuleFileName(pM sg->hwnd,f ileBuff,25 6);
#include <WINABLE.H>
TCHAR fileBuff[256];
GetWindowModuleFileName(pM
The Q is answered