0

嗨,我正在尝试使用以下脚本在计算机上查找 DVD 驱动器。GetDriveType 总是返回 1,即使我手动传递驱动器号它仍然返回 1,有谁能告诉我为什么会这样,我对 nsis 脚本完全陌生

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:
4

1 回答 1

1

正确的语法是System::Call 'kernel32::GetDriveType(tr#)i.r#'(逗号是参数分隔符,.表示没有输入,在这种情况下您有输入):

!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
于 2012-08-24T22:18:35.653 回答