1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| void CGethdlView::OnTimer(UINT_PTR nIDEvent)
{
// TODO : ajoutez ici le code de votre gestionnaire de messages et/ou les paramètres par défaut des appels
CString str_a;
CString str_b;
LPWSTR str_c = new _TCHAR[100];
HWND hwnd_a=::GetForegroundWindow();
DWORD erreur=GetLastError();
str_b.Format(_T("GetForegroundWindow : %d"),erreur);
AfxMessageBox(str_b,MB_OK|MB_APPLMODAL,1);
HANDLE c=NULL;
DWORD* prhnd= new DWORD;
PDWORD lng =new DWORD;
GetWindowThreadProcessId(hwnd_a,prhnd);
erreur=GetLastError();
str_b.Format(_T("GetForegroundWindow : %d"),erreur);
AfxMessageBox(str_b,MB_OK|MB_APPLMODAL,1);
str_a.Format(_T("%p"),prhnd);
edt_HDL.SetWindowText(str_a);
c=OpenProcess(PROCESS_QUERY_INFORMATION,TRUE,*prhnd);
erreur=GetLastError();
str_b.Format(_T("Open process : %d"),erreur);
AfxMessageBox(str_b,MB_OK|MB_APPLMODAL,1);
if(c==NULL)
{
erreur=GetLastError();
str_b.Format(_T("Open process : %d"),erreur);
AfxMessageBox(str_b,MB_OK|MB_APPLMODAL,1);
}
else
{
if(QueryFullProcessImageName(c,PROCESS_NAME_NATIVE,str_c,lng))
//str_b.Format(_T("%p"),c);
edt_Nom.SetWindowTextW(str_c);
else
{
erreur=GetLastError();
str_b.Format(_T("QuerryFullProcessImageName : %d"),erreur);
AfxMessageBox(str_b,MB_OK|MB_APPLMODAL,1);
}
}
CFormView::OnTimer(nIDEvent);
} |
Partager