/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App.CsWin32/Extras.cs
52 строки
2 KB
0x5bfa
Code Quality: Replace raw ABI pointers with ComObject instances for safer disposal (#18684)
16 июл 2026, 18:32
Не верифицирован
16 июл 2026, 18:32
93dfb04
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using Windows.Win32.Foundation; using Windows.Win32.Graphics.DirectComposition; using Windows.Win32.Graphics.Gdi; using Windows.Win32.UI.WindowsAndMessaging; namespace Windows.Win32 { public static partial class PInvoke { [LibraryImport("User32", EntryPoint = "SetWindowLongW")] private static partial int _SetWindowLong(nint hWnd, int nIndex, int dwNewLong); [LibraryImport("User32", EntryPoint = "SetWindowLongPtrW")] private static partial nint _SetWindowLongPtr(nint hWnd, int nIndex, nint dwNewLong); // 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 ? (nint)_SetWindowLong(hWnd, (int)nIndex, (int)dwNewLong) : _SetWindowLongPtr(hWnd, (int)nIndex, dwNewLong); } [LibraryImport("shell32.dll", EntryPoint = "SHUpdateRecycleBinIcon", SetLastError = true)] public static partial void SHUpdateRecycleBinIcon(); public const int PixelFormat32bppARGB = 2498570; } namespace Extras { [UnmanagedFunctionPointer(CallingConvention.Winapi)] public unsafe delegate BOOL ManagedMONITORENUMPROC([In] HMONITOR param0, [In] HDC param1, [In][Out] RECT* param2, [In] LPARAM param3); [UnmanagedFunctionPointer(CallingConvention.Winapi)] public delegate LRESULT ManagedWNDPROC(HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam); [GeneratedComInterface, Guid("EACDD04C-117E-4E17-88F4-D1B12B0E3D89"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public partial interface IDCompositionTarget { [PreserveSig] int SetRoot(IDCompositionVisual visual); } } }