44
55namespace Windows . Win32 ;
66
7- // Edited from: https://github.com/files-community/Files
87internal static partial class PInvoke
98{
9+ // SetWindowLong
10+ // Edited from: https://github.com/files-community/Files
11+
1012 [ DllImport ( "User32" , EntryPoint = "SetWindowLongW" , ExactSpelling = true ) ]
11- static extern int _SetWindowLong ( HWND hWnd , int nIndex , int dwNewLong ) ;
13+ private static extern int _SetWindowLong ( HWND hWnd , int nIndex , int dwNewLong ) ;
1214
1315 [ DllImport ( "User32" , EntryPoint = "SetWindowLongPtrW" , ExactSpelling = true ) ]
14- static extern nint _SetWindowLongPtr ( HWND hWnd , int nIndex , nint dwNewLong ) ;
16+ private static extern nint _SetWindowLongPtr ( HWND hWnd , int nIndex , nint dwNewLong ) ;
1517
1618 // NOTE:
1719 // CsWin32 doesn't generate SetWindowLong on other than x86 and vice versa.
@@ -22,4 +24,22 @@ public static unsafe nint SetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nInd
2224 ? _SetWindowLong ( hWnd , ( int ) nIndex , ( int ) dwNewLong )
2325 : _SetWindowLongPtr ( hWnd , ( int ) nIndex , dwNewLong ) ;
2426 }
27+
28+ // GetWindowLong
29+
30+ [ DllImport ( "User32" , EntryPoint = "GetWindowLongW" , ExactSpelling = true ) ]
31+ private static extern int _GetWindowLong ( HWND hWnd , int nIndex ) ;
32+
33+ [ DllImport ( "User32" , EntryPoint = "GetWindowLongPtrW" , ExactSpelling = true ) ]
34+ private static extern nint _GetWindowLongPtr ( HWND hWnd , int nIndex ) ;
35+
36+ // NOTE:
37+ // CsWin32 doesn't generate GetWindowLong on other than x86 and vice versa.
38+ // For more info, visit https://github.com/microsoft/CsWin32/issues/882
39+ public static unsafe nint GetWindowLongPtr ( HWND hWnd , WINDOW_LONG_PTR_INDEX nIndex )
40+ {
41+ return sizeof ( nint ) is 4
42+ ? _GetWindowLong ( hWnd , ( int ) nIndex )
43+ : _GetWindowLongPtr ( hWnd , ( int ) nIndex ) ;
44+ }
2545}
0 commit comments