[c#获取远程连接到计算机的用户的IP地址

问题描述 投票:0回答:2

我正在Windows服务中使用以下c#代码捕获远程连接和断开事件。

我如何获得远程连接到该计算机的最终用户的IP地址。

protected override void OnSessionChange(SessionChangeDescription changeDescription)
 {
        switch (changeDescription.Reason)
        {
            case SessionChangeReason.RemoteConnect:
                //Remote Connect
                break;
            case SessionChangeReason.RemoteDisconnect:
                //Remote Disconnect
                break;
            default:
                break;
        }
 }
c# windows-services ip-address remote-connection
2个回答
1
投票

[我在c#中找到了相关的解决方案,它使用PInvoke WTSQuerySessionInformationWTS_INFO_CLASS.WTSClientAddress

有关更多详细信息,您可以转到此处:Grabbing Information of a Terminal Services Session Programmatically


0
投票

这是您问题的答案;

Detect source of remote desktop connection

仅表示您可以查询连接并解析它们。

© www.soinside.com 2019 - 2024. All rights reserved.