public static IntPtr GetWindowLongPtr(IntPtr hwnd, GWL nIndex) { IntPtr intPtr = IntPtr.Zero; if (8 == IntPtr.Size) { intPtr = NativeMethods.GetWindowLongPtr64(hwnd, nIndex); } else { intPtr = new IntPtr(NativeMethods.GetWindowLongPtr32(hwnd, nIndex)); } if (IntPtr.Zero == intPtr) { throw new Win32Exception(); } return(intPtr); }