我使用GetWindowLong這樣的:GetWindowLong VS GetWindowLongPtr在C#
[DllImport("user32.dll")]
private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
但根據MSDN文檔我應該使用GetWindowLongPtr將64位兼容。 http://msdn.microsoft.com/en-us/library/ms633584(VS.85).aspx
MSDN文檔爲GetWindowLongPtr說,我應該把它定義像這樣(用C++):
LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex);
我以前使用的IntPtr返回類型,但赫克我會用什麼LONG_PTR的等價物?我也看到GetWindowLong在C#中將其定義爲:
[DllImport("user32.dll")]
private static extern long GetWindowLong(IntPtr hWnd, int nIndex);
什麼是正確的,以及如何確保正確的64位兼容性?
這兩個DllImport語句都不正確:在64位Windows上,GetWindowLong不返回IntPtr,並且在32位Windows上,GetWindowLong不返回長整型。 – 2008-11-26 03:45:08