【问题标题】:c# getting ip address of user who remotely connect to machinec#获取远程连接机器的用户的ip地址
【发布时间】:2014-11-30 05:47:46
【问题描述】:

我在 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


    【解决方案1】:

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

    更多详情,你可以去这里: Grabbing Information of a Terminal Services Session Programmatically

    来自 Selvin 的说明:解决方案不会释放返回的缓冲区...您应该致电 WTSFreeMemory(pAddress)

    【讨论】:

      【解决方案2】:

      这是您问题的答案;

      Detect source of remote desktop connection

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-22
        • 2011-05-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-01
        • 2011-06-13
        • 2015-08-19
        相关资源
        最近更新 更多