查找最大驱动器,NSIS安装程序

时间:2012-08-16 16:52:29

标签: installer nsis

我是NSIS安装程序脚本的新手,我想将安装目录设置为计算机上最大的磁盘。任何人都可以指导我如何做到这一点。

1 个答案:

答案 0 :(得分:2)

!include LogicLib.nsh
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
        System::Call 'kernel32::GetDiskFreeSpaceEx(tr3,*l.r5,*l,*l)i'
        ${If} $5 L> $2
            StrCpy $2 $5
            StrCpy $1 $3
        ${EndIf}
    ${EndIf}
    IntOp $4 $4 + 1
    IntOp $0 $0 >> 1
    StrCmp $0 0 "" loop
StrCpy $InstDir "$1" ;You should probably append something to the path here, you cannot install to the root of a drive by default

将它放在.onInit或目录页面的预回调中......