找回密码
 加入
搜索
查看: 3198|回复: 5

[系统综合] 数据取值问题. 谢谢

[复制链接]
发表于 2012-2-21 14:06:55 | 显示全部楼层 |阅读模式
本帖最后由 非典男人 于 2012-2-21 14:13 编辑

以下代码运行后的效果图,请问如何将数组中指定的内容单独显示或者发送给变量赋值,谢谢.
    同时有个新的问题,就是在 通过mstsc连接服务器时如何实现获取客户端计算机的IP地址,
以下代码是pusofalse提供, 已经可以获得 客户端计算机名,但是无法获取到客户端计算机的IP地址.感谢pusofalse的帮助.


#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_UseX64=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Array.au3>
 Dim $hServer
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-21 14:15:54 | 显示全部楼层
$aSession[1][5]  ?
 楼主| 发表于 2012-2-21 14:20:29 | 显示全部楼层
回复 2# bdancerlc


    是的  主要是 数组中的 内容 如何 让单独取出.
 楼主| 发表于 2012-2-23 09:15:11 | 显示全部楼层
麻烦懂的给指点指点, 非常感谢.
发表于 2012-2-23 18:48:06 | 显示全部楼层
回复 4# 非典男人


    发现木马。。。
代码犀利的很那
发表于 2012-2-24 17:26:08 | 显示全部楼层
回复 3# 非典男人


    单独取出数组中某一数值?这个不是基础吗?
  $a = $aSession[1][5] 之类的操作方法。不知道你说的是不是这个意思。
  如果要循环判断
  $a = $aSession[$i][5]
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-6 06:04 , Processed in 0.081875 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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