I m trying to get a call to EnumThreadWindows working, but I always get a Wrong Parameter-Error, although my code is nearly the same as this example on pinvoke.net. I don t know why this doesn t work:
public static IntPtr FindMsgBoxFrom(IntPtr MainHWND)
{
SetLastError(0);
uint ThreadID = GetThreadID(MainHWND);
EnumThreadWindows(ThreadID, new WNDENUMPROC(decoder.FindMsgBox), IntPtr.Zero);
int last = Marshal.GetLastWin32Error();
if (last != 0)
MessageBox.Show("EnumThreadWindows-Error:
" + GetLastErrorString());
return MSGHWND;
}
and this is decoder.FindMsgBox
:
public static bool FindMsgBox(IntPtr hwnd, IntPtr lparam)
{
if (IsMsgBox(hwnd))
{
MSGHWND = hwnd;
return false;
}
else
return true;
}
}
What s the problem with this?