Find Largest Drive, NSIS installer

一世执手 提交于 2019-12-08 06:33:49

问题


I am completely new to NSIS installer script, I want to set the install directory to the largest disk on the computer. Can anyone guide me how to do it.


回答1:


!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

Put it in .onInit or the pre callback for your directory page...



来源:https://stackoverflow.com/questions/11991962/find-largest-drive-nsis-installer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!