【问题标题】:Find Largest Drive, NSIS installer查找最大驱动器,NSIS 安装程序
【发布时间】:2012-08-16 16:52:29
【问题描述】:

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

【问题讨论】:

  • 使用 $ProgramFiles\YourApp 作为默认值通常更有意义...
  • 您还应该记住,卷可以安装在 NTFS 上的文件夹中,因此仅检查驱动器号可能找不到最大的卷...

标签: installation nsis


【解决方案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

将它放入 .onInit 或目录页面的 pre 回调中...

【讨论】:

  • 此代码检查可用空间,因为安装程序这样做更有意义,并且可以避免只读卷...
  • 太棒了!我完成了安装部分。安装可执行文件后,我需要提示用户插入另一张 DVD 以安装实用程序。你能指导我怎么做吗
  • 如果它与这个问题无关,那么你应该问一个新问题(如果它是正确的,请接受这个答案)
  • ${如果} $3 0;这句话有什么作用?
  • 如果 $3 不是 0 的数字,那么...(我们只需要有效的驱动器号)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-29
  • 1970-01-01
  • 1970-01-01
  • 2014-08-30
  • 1970-01-01
相关资源
最近更新 更多