找回密码
 加入
搜索
查看: 7779|回复: 7

[网络通信] [已解决]请问如何获取远程桌面登录的客户端计算机名和IP

  [复制链接]
发表于 2012-2-17 11:39:51 | 显示全部楼层 |阅读模式
本帖最后由 非典男人 于 2012-2-21 08:58 编辑

请问如何获取远程桌面登录的客户端计算机名和 IP  谢谢
具体如图所示:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-2-17 15:38:49 | 显示全部楼层
我能想到的办法和AU3关系不大了  一个是用AU3读取该listview控件的值  得到MR_G后 内网的话可以ping 这个计算机名得到IP  或者用netstat -an |find "3389" |find "ESTABLISHED"可以得到正在连接的客户端IP
命令query user能得到一些相关信息。
发表于 2012-2-17 23:02:11 | 显示全部楼层
系统日志安全性里面看看有没有。
发表于 2012-2-18 01:59:33 | 显示全部楼层
没有注意过着东西哦
发表于 2012-2-18 03:51:04 | 显示全部楼层
#include <Array.au3>

Const $tagWTS_SESSION_INFO = "long SessionID;ptr SessionName;long State"

Func _WTSEnumSessions($hServer)
        Local $iResult
        $iResult = DllCall("Wtsapi32.dll", "bool", "WTSEnumerateSessionsW", "handle", $hServer, "long", 0, "long", 1, "ptr*", 0, "long*", 0)

        Local $aResult[$iResult[5] + 1][7] = [[$iResult[5]]]

        TCPStartup()

        For $i = 1 To $aResult[0][0]
                $tSessionInfo = DllStructCreate($tagWTS_SESSION_INFO, $iResult[4] + ($i - 1) * (@AutoItX64 + 1) * 12)

                $aResult[$i][0] = DllStructGetData($tSessionInfo, "SessionID")
                $aResult[$i][1] = DllStructGetData($tSessionInfo, "State")

                $aResult[$i][2] = _WTSReadStringW( DllStructGetData($tSessionInfo, "SessionName"), 0)
                $aResult[$i][3] = _WTSReadStringW(_WTSQuerySessionData($hServer, $aResult[$i][0], 7)) ; Domain name
                $aResult[$i][4] = _WTSReadStringW(_WTSQuerySessionData($hServer, $aResult[$i][0], 5)) ; User name
                $aResult[$i][5] = _WTSReadStringW(_WTSQuerySessionData($hServer, $aResult[$i][0], 10)) ; Client name
                $aResult[$i][6] = _GetHostIPAddresses($aResult[$i][3])

        Next
        DllCall("Wtsapi32.dll", "none", "WTSFreeMemory", "ptr", $iResult[4])

        Return $aResult
EndFunc        ;==>_WTSEnumSessions

Func _WTSReadStringW($pStringW, $fFree = 1)
        If $pStringW = 0 Then Return ""

        Local $iResult
        $iResult = DllCall("Kernel32.dll", "long", "lstrlenW", "ptr", $pStringW)
        $iResult = DllCall("Kernel32.dll", "none", "RtlMoveMemory", "wstr", "", "ptr", $pStringW, "long", $iResult[0] * 2 + 2)

        If $fFree Then DllCall("Wtsapi32.dll", "none", "WTSFreeMemory", "ptr", $pStringW)

        Return $iResult[1]
EndFunc        ;==>_WTSReadStringW

Func _WTSQuerySessionData($hServer, $iSessionID, $iInfoClass)
        Local $iResult
        $iResult = DllCall("Wtsapi32.dll", "bool", "WTSQuerySessionInformationW", "ptr", $hServer, "long", $iSessionID, "long", $iInfoClass, "ptr*", 0, "long*", 0)

        Return SetError(0, $iResult[5], $iResult[4])
EndFunc        ;==>_WTSQuerySessionData

Func _GetHostIPAddresses($sHostName)
        Local $iResult
        $iResult = DllCall("Ws2_32.dll", "ptr", "gethostbyname", "str", $sHostName)
        If $iResult[0] = 0 Then Return ""

        Local $tHostent = DllStructCreate("ptr name;ptr aliases;word addrtype;word length;ptr addrlist", $iResult[0])
        Local $pAddrList = DllStructGetData($tHostent, "addrlist")

        Local $tAddress, $pAddress, $tLONG, $iResult, $sResult

        For $i = 0 To 1023
                $tAddress = DllStructCreate("ptr address", $pAddrList + $i * ((@AutoItX64 + 1) * 4))
                $pAddress = DllStructGetData($tAddress, "address")

                If $pAddress = 0 Then ExitLoop

                $tLONG = DllStructCreate("long LONG", $pAddress)
                $iResult = DllCall("Ws2_32.dll", "str", "inet_ntoa", "long", DllStructGetData($tLONG, "LONG"))

                $sResult &= $iResult[0] & ", "
        Next
        Return StringTrimRight($sResult, 2)
EndFunc        ;==>_GetHostIPAddresses


$aSession = _WTSEnumSessions(0)
_ArrayDisplay($aSession)
 楼主| 发表于 2012-2-18 20:24:41 | 显示全部楼层
回复 5# pusofalse


    太感谢了,不过还得指教下,怎么样把 数组里面的 客户端计算机名 单独发送到变量赋值呢?
发表于 2012-12-5 10:44:06 | 显示全部楼层
发表于 2014-7-22 14:07:20 | 显示全部楼层
mark,这个不错
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-12 03:09 , Processed in 0.147008 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表