|
Suppose more than one application is running in my system. I want my program to trace all the popup exceptions i.e. error messages from other applications.
Can anybody help me in this with a simple VC++ example????
|
|
|
|
|
|
<pre lang="text">Thanks a lot <b>Alan </b>
I tried the following code. It is giving me the title of every open windows. But I want only the exception popup window( i.e. error windows generated from other applications) from them.How could I get this. Plz help me.</pre>
<pre lang="c++">
BOOL CALLBACK MyEnumProc(HWND hWnd, LPARAM lParam)
{
TCHAR title[500];
ZeroMemory(title, sizeof(title));
GetWindowText(hWnd, title, sizeof(title)/sizeof(title[0]));
CString msg=L"";
msg.Format(_T("Value is %s\n"), title);
AfxMessageBox(msg);
return TRUE;
}
void CEnumWindowTest1Dlg::MyFunc(void) //(called by main)
{
EnumWindows(MyEnumProc, 0);
}
</pre>
|
|
|
|
|
Without seeing those titles, I can't give you a way of distinguishing them. If the titles don't work, then using the windows' handles, you can probably get the applications or processes that own them. Then you can use this information to isolate the ones you want.
|
|
|
|
|
<pre lang="text">
<b>Alan</b>
Yes I can get the IDs of each thread with the API GetWindowThreadProcessId()
DWORD threadId = GetWindowThreadProcessId(hWnd, NULL);
now if I go to each thread and call GetLastError() then I am able to know which of them are error windows.
But I don't know how can to call GetLastError() for each thread with threadId.
</pre>
|
|
|
|
|
You cannot use GetLastError() in this way, it will only return the last error value in the current thread of your application. And even if you could somehow call it you would not get a valid response. I think you will find that this project is not viable.
|
|
|
|