Fixed bug in GetWindowLongAuto per #442

nullableenabled
David Hall 2024-03-25 16:07:46 -06:00
parent 45c0a6869c
commit 8ea569f81c
1 changed files with 3 additions and 6 deletions

View File

@ -2493,13 +2493,10 @@ public static partial class User32
/// </returns>
public static IntPtr GetWindowLongAuto(HWND hWnd, WindowLongFlags nIndex)
{
IntPtr ret;
if (IntPtr.Size == 4)
ret = (IntPtr)GetWindowLong(hWnd, nIndex);
else
ret = GetWindowLongPtr(hWnd, nIndex);
SetLastErrorEx(0, 0);
IntPtr ret = IntPtr.Size == 4 ? GetWindowLong(hWnd, nIndex) : GetWindowLongPtr(hWnd, nIndex);
if (ret == IntPtr.Zero)
throw new System.ComponentModel.Win32Exception();
Win32Error.GetLastError().ThrowIfFailed();
return ret;
}