2012-08-24 102 views
0

嗨我正試圖找到下面的腳本在計算機上的DVD驅動器。 GetDriveType總是返回1,即使我手動傳遞盤符仍然會返回1,可以在任何告訴我爲什麼做這樣的,我是完全新的NSIS腳本GetDriveType總是返回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: 

回答

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