2025-03-16 15:18:50 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using Windows.Win32.Foundation;
|
|
|
|
|
|
using Windows.Win32.UI.WindowsAndMessaging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Windows.Win32;
|
|
|
|
|
|
|
|
|
|
|
|
internal static partial class PInvoke
|
|
|
|
|
|
{
|
2025-05-24 05:10:25 +00:00
|
|
|
|
// SetWindowLong
|
|
|
|
|
|
// Edited from: https://github.com/files-community/Files
|
|
|
|
|
|
|
2025-03-16 15:18:50 +00:00
|
|
|
|
[DllImport("User32", EntryPoint = "SetWindowLongW", ExactSpelling = true)]
|
2025-05-24 05:10:25 +00:00
|
|
|
|
private static extern int _SetWindowLong(HWND hWnd, int nIndex, int dwNewLong);
|
2025-03-16 15:18:50 +00:00
|
|
|
|
|
|
|
|
|
|
[DllImport("User32", EntryPoint = "SetWindowLongPtrW", ExactSpelling = true)]
|
2025-05-24 05:10:25 +00:00
|
|
|
|
private static extern nint _SetWindowLongPtr(HWND hWnd, int nIndex, nint dwNewLong);
|
2025-03-16 15:18:50 +00:00
|
|
|
|
|
|
|
|
|
|
// NOTE:
|
|
|
|
|
|
// CsWin32 doesn't generate SetWindowLong on other than x86 and vice versa.
|
|
|
|
|
|
// For more info, visit https://github.com/microsoft/CsWin32/issues/882
|
|
|
|
|
|
public static unsafe nint SetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sizeof(nint) is 4
|
|
|
|
|
|
? _SetWindowLong(hWnd, (int)nIndex, (int)dwNewLong)
|
|
|
|
|
|
: _SetWindowLongPtr(hWnd, (int)nIndex, dwNewLong);
|
|
|
|
|
|
}
|
2025-05-24 05:10:25 +00:00
|
|
|
|
|
|
|
|
|
|
// GetWindowLong
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("User32", EntryPoint = "GetWindowLongW", ExactSpelling = true)]
|
|
|
|
|
|
private static extern int _GetWindowLong(HWND hWnd, int nIndex);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("User32", EntryPoint = "GetWindowLongPtrW", ExactSpelling = true)]
|
|
|
|
|
|
private static extern nint _GetWindowLongPtr(HWND hWnd, int nIndex);
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE:
|
|
|
|
|
|
// CsWin32 doesn't generate GetWindowLong on other than x86 and vice versa.
|
|
|
|
|
|
// For more info, visit https://github.com/microsoft/CsWin32/issues/882
|
|
|
|
|
|
public static unsafe nint GetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sizeof(nint) is 4
|
|
|
|
|
|
? _GetWindowLong(hWnd, (int)nIndex)
|
|
|
|
|
|
: _GetWindowLongPtr(hWnd, (int)nIndex);
|
|
|
|
|
|
}
|
2025-03-16 15:18:50 +00:00
|
|
|
|
}
|