d2phap / ImageGlass

🏞 A lightweight, versatile image viewer
https://imageglass.org
Other
7.54k stars 491 forks source link

\ImageGlass.WinTouch\NativeMethods.cs PInvoke.GetGestureInfo error when Microsoft.Windows.CsWin32 update to 0.3.106 #1920

Closed Charltsing closed 4 months ago

Charltsing commented 4 months ago

Components\ImageGlass.WinTouch\NativeMethods.cs line 83 var result = PInvoke.GetGestureInfo(new HGESTUREINFO(gestureInfoHandle), out pGestureInfo);

the first parameter type is error when Microsoft.Windows.CsWin32 update to 0.3.106, it should be SafeHandle

How to change the first parameter type to safehandle?

internal static unsafe winmdroot.Foundation.BOOL GetGestureInfo(SafeHandle hGestureInfo, out winmdroot.UI.Input.Touch.GESTUREINFO pGestureInfo) { bool hGestureInfoAddRef = false; try { fixed (winmdroot.UI.Input.Touch.GESTUREINFO* pGestureInfoLocal = &pGestureInfo) { winmdroot.UI.Input.Touch.HGESTUREINFO hGestureInfoLocal; if (hGestureInfo is object) { hGestureInfo.DangerousAddRef(ref hGestureInfoAddRef); hGestureInfoLocal = (winmdroot.UI.Input.Touch.HGESTUREINFO)hGestureInfo.DangerousGetHandle(); } else throw new ArgumentNullException(nameof(hGestureInfo)); winmdroot.Foundation.BOOL result = PInvoke.GetGestureInfo(hGestureInfoLocal, pGestureInfoLocal); return result; } } finally { if (hGestureInfoAddRef) hGestureInfo.DangerousRelease(); } }