4
4
5
5
namespace Windows . Win32 ;
6
6
7
- // Edited from: https://github.com/files-community/Files
8
7
internal static partial class PInvoke
9
8
{
9
+ // SetWindowLong
10
+ // Edited from: https://github.com/files-community/Files
11
+
10
12
[ 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 ) ;
12
14
13
15
[ 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 ) ;
15
17
16
18
// NOTE:
17
19
// 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
22
24
? _SetWindowLong ( hWnd , ( int ) nIndex , ( int ) dwNewLong )
23
25
: _SetWindowLongPtr ( hWnd , ( int ) nIndex , dwNewLong ) ;
24
26
}
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
+ }
25
45
}
0 commit comments