查找最大的驱动器,NSIS安装程序 [英] Find Largest Drive, NSIS installer

查看:86
本文介绍了查找最大的驱动器,NSIS安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对NSIS安装程序脚本完全陌生,我想将安装目录设置为计算机上最大的磁盘.谁能指导我该怎么做.

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.

推荐答案

!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或目录页面的预回调中...

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

这篇关于查找最大的驱动器,NSIS安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆