all day I'm trying to get EnumThreadWindows working, but I always get a Wrong Parameter-Error although my code is nearly the same as on pinvoke.net!! dont know why this doesnt 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:\n" + 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; }
Whats the problem with this?