- Notifications
You must be signed in to change notification settings - Fork 364
/
Copy pathPInvokeExtensions.cs
25 lines (21 loc) · 1006 Bytes
/
PInvokeExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
usingSystem.Runtime.InteropServices;
usingWindows.Win32.Foundation;
usingWindows.Win32.UI.WindowsAndMessaging;
namespaceWindows.Win32;
// Edited from: https://github.com/files-community/Files
internalstaticpartialclassPInvoke
{
[DllImport("User32",EntryPoint="SetWindowLongW",ExactSpelling=true)]
staticexternint_SetWindowLong(HWNDhWnd,intnIndex,intdwNewLong);
[DllImport("User32",EntryPoint="SetWindowLongPtrW",ExactSpelling=true)]
staticexternnint_SetWindowLongPtr(HWNDhWnd,intnIndex,nintdwNewLong);
// NOTE:
// CsWin32 doesn't generate SetWindowLong on other than x86 and vice versa.
// For more info, visit https://github.com/microsoft/CsWin32/issues/882
publicstaticunsafenintSetWindowLongPtr(HWNDhWnd,WINDOW_LONG_PTR_INDEXnIndex,nintdwNewLong)
{
returnsizeof(nint)is4
?_SetWindowLong(hWnd,(int)nIndex,(int)dwNewLong)
:_SetWindowLongPtr(hWnd,(int)nIndex,dwNewLong);
}
}