找回密码
 加入
搜索
查看: 1712|回复: 3

[AU3基础] [已解决]api函数GetLogicalDriveStrings问题

[复制链接]
发表于 2010-11-24 19:12:21 | 显示全部楼层 |阅读模式
本帖最后由 风行者 于 2010-11-26 10:45 编辑

下面代码为什么只返回一个盘符,应该是所有盘符显示才对
不知道哪里问题?
$stString  = DLLStructCreate("char ui[1024]")
DllCall("Kernel32.dll","DWORD","GetLogicalDriveStrings","DWORD",1023,"ptr",DllStructGetPtr($stString))
$sFileName  = DllStructGetData($stString,"ui")
MsgBox(0,"",$sFileName)
发表于 2010-11-24 21:01:54 | 显示全部楼层
$stString中的数据是以NULL字符相分隔的,用StringLen函数取得下一字符串的偏移地址,指针加上该偏移就是下一个字符串,最后的一个字符串是以2个NULL字符隔开的。
 楼主| 发表于 2010-11-24 21:46:20 | 显示全部楼层
能不能举个例子
发表于 2010-11-24 23:39:06 | 显示全部楼层

$tBuffer = DllStructCreate("char ui[1024]")
$pBuffer = DllStructGetPtr($tBuffer)

$iResult = DllCall("Kernel32.dll", "dword", "GetLogicalDriveStrings", "dword", 1024, "ptr", $pBuffer)

While 1
        $tDrive = DllStructCreate("char ui[8]", $pBuffer)
        $sDrive = DllStructGetData($tDrive, "ui")
        If ($sDrive = "") Then ExitLoop

        MsgBox(0, "", $sDrive)
        $pBuffer += StringLen($sDrive) + 1
WEnd

评分

参与人数 1金钱 +20 收起 理由
风行者 + 20 学习了

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 23:39 , Processed in 0.084234 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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