A
Alex
Hello,
I have a problem with Marshal.GetLastWin32Error()
Every call returns 127 (ERROR_PROC_NOT_FOUND) even if the previous call was successful.
For example, given:
namespace Utils
{
public class Win32
{
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
}
}
And this code:
int rc;
IntPtr hwnd = Win32.FindWindow("something", "something else");
rc = Marshal.GetLastWin32Error();
The call to FindWindow() succeeds (hwnd gets a non-null value)
but Marshal.GetLastWin32Error() returns 127.
What am I doing wrong?
Thanks,
Alex.
I have a problem with Marshal.GetLastWin32Error()
Every call returns 127 (ERROR_PROC_NOT_FOUND) even if the previous call was successful.
For example, given:
namespace Utils
{
public class Win32
{
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
}
}
And this code:
int rc;
IntPtr hwnd = Win32.FindWindow("something", "something else");
rc = Marshal.GetLastWin32Error();
The call to FindWindow() succeeds (hwnd gets a non-null value)
but Marshal.GetLastWin32Error() returns 127.
What am I doing wrong?
Thanks,
Alex.