首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GetDriveType始终返回1个nsis

GetDriveType始终返回1个nsis
EN

Stack Overflow用户
提问于 2012-08-25 04:45:42
回答 1查看 388关注 0票数 0

嗨,我正在尝试用下面的脚本在电脑上找到DVD驱动器。GetDriveType总是返回1,即使我手动传递驱动器号,它仍然返回1,您能告诉我为什么会这样吗?我对nsis脚本完全陌生

代码语言:javascript
复制
System::Call 'kernel32::GetLogicalDrives()i.r0'
StrCpy $1 $windir 3 ; Fallback if things go wrong
StrCpy $2 0
StrCpy $4 65 ; 'A'
loop:
    IntOp $3 $0 & 1
    ${If} $3 <> 0
        IntFmt $3 "%c:\" $4
        MessageBox MB_OK "Drive : $3"
        System::Call 'kernel32::GetDriveType(t,.r3)i.r5'
        MessageBox MB_OK "Value of 5555555: $5"
        StrCmp $5 5 0 NoDrive
            MessageBox MB_OK "Found drive $3"
            StrCpy $1 $3
        Nodrive:
            ;do nothing
    ${EndIf}
    IntOp $4 $4 + 1
    IntOp $0 $0 >> 1
StrCmp $0 0 "" loop
System::Call 'kernel32::GetDriveType(t,"D:\")i.r5'
StrCmp $5 5 0 NoDr
    MessageBox MB_OK "Found D as $D"
NoDr:
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-25 06:18:36

正确的语法是System::Call 'kernel32::GetDriveType(tr#)i.r#' (逗号是参数分隔符,.表示没有输入,本例中有输入):

代码语言:javascript
复制
!include LogicLib.nsh
System::Call 'kernel32::GetLogicalDrives()i.r0'
StrCpy $2 0
StrCpy $4 65 ; 'A'
loop:
    IntOp $3 $0 & 1
    ${If} $3 <> 0
        IntFmt $3 "%c:\" $4
        System::Call 'kernel32::GetDriveType(tr3)i.r5'
        DetailPrint "$3=$5"
    ${EndIf}
    IntOp $4 $4 + 1
    IntOp $0 $0 >> 1
StrCmp $0 0 "" loop
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12116408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档