From 68f6ffc2026312905fa7a0d10458942ec7a14d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Sat, 16 Nov 2024 21:57:29 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E4=BF=AE=E6=AD=A3win10+net9=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=9C=A8=E5=90=8E=E5=8F=B0=E6=9C=8D=E5=8A=A1=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=89=8D=E5=8F=B0=E8=BF=9B=E7=A8=8B=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NewLife.Agent/Windows/Desktop.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/NewLife.Agent/Windows/Desktop.cs b/NewLife.Agent/Windows/Desktop.cs index d2b8054..1cbc826 100644 --- a/NewLife.Agent/Windows/Desktop.cs +++ b/NewLife.Agent/Windows/Desktop.cs @@ -290,6 +290,15 @@ private static UInt32 GetFirstActiveSessionOfEnumerateSessions() var arrayElementSize = Marshal.SizeOf(typeof(WtsSessionInfo)); var current = pSessionInfo; + /* + * 常见会话: + * 0, Services, WTSDisconnected + * 1, Console, WTSActive + * 2, "", WTSDisconnected -YiFan + * 3, "", WTSDisconnected -YiFei + * 65536, 31C5CE94259D4006A9E4, WTSListen + * 65537, RDP-Tcp, WTSListen + */ for (var i = 0; i < sessionCount; i++) { var si = (WtsSessionInfo)Marshal.PtrToStructure(current, typeof(WtsSessionInfo)); @@ -308,9 +317,8 @@ private static UInt32 GetFirstActiveSessionOfEnumerateSessions() // 清理资源 if (pSessionInfo != IntPtr.Zero) { - WTSFreeMemory(pSessionInfo); //如果没有判断是否为IntPtr.Zero,会导致引发SEHException异常:"external component has thrown an exception" - CloseHandle(pSessionInfo); + WTSFreeMemory(pSessionInfo); } } }