我建议您以Windows窗体内部执行的方式处理此问题:
public static IntPtr GetWindowLong(HandleRef hWnd, int nIndex){ if (IntPtr.Size == 4) { return GetWindowLong32(hWnd, nIndex); } return GetWindowLongPtr64(hWnd, nIndex);}[Dllimport("user32.dll", EntryPoint="GetWindowLong", CharSet=CharSet.Auto)]private static extern IntPtr GetWindowLong32(HandleRef hWnd, int nIndex);[Dllimport("user32.dll", EntryPoint="GetWindowLongPtr", CharSet=CharSet.Auto)]private static extern IntPtr GetWindowLongPtr64(HandleRef hWnd, int nIndex);


