[英]c# getting ip address of user who remotely connect to machine
I am using following piece of c# code in windows service to capture Remote connect and disconnect events.我在 Windows 服务中使用以下 c# 代码来捕获远程连接和断开连接事件。
How I can get the IPaddress of end user who remotely connect to that machine.如何获取远程连接到该机器的最终用户的 IP 地址。
protected override void OnSessionChange(SessionChangeDescription changeDescription)
{
switch (changeDescription.Reason)
{
case SessionChangeReason.RemoteConnect:
//Remote Connect
break;
case SessionChangeReason.RemoteDisconnect:
//Remote Disconnect
break;
default:
break;
}
}
I found related solution in c#, it's using PInvoke WTSQuerySessionInformation
with WTS_INFO_CLASS.WTSClientAddress
我在 c# 中找到了相关的解决方案,它使用 PInvoke
WTSQuerySessionInformation
和WTS_INFO_CLASS.WTSClientAddress
For more details you can go here: Grabbing Information of a Terminal Services Session Programmatically有关更多详细信息,您可以访问此处: 以编程方式获取终端服务会话的信息
Note from Selvin: solution doesn't free returned buffer ... you sould call WTSFreeMemory(pAddress)
Selvin 的注释:解决方案不会释放返回的缓冲区......你应该调用
WTSFreeMemory(pAddress)
Here is the answer to your question;这是您问题的答案;
Detect source of remote desktop connection 检测远程桌面连接的来源
It simply indicates that you can query the connections and parse them.它只是表明您可以查询连接并解析它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.