最新消息:

NSIS获取最大容量盘符和最大剩余空间

nsis 永恒心锁 1996浏览 0评论
include "FileFunc.nsh"
!include "LogicLib.nsh"
OutFile "Demo.exe"
SilentInstall silent
Section
 ;查找所有硬盘驱动器(HDD)
 ${GetDrives} "HDD" "FindHDD"
 MessageBox MB_OK "最大可用空间驱动器盘符:$R2"
SectionEnd
Function "FindHDD"
 ;获取查找到的驱动器盘符($9)可用空间(/D=F)单位兆(/S=M)
 ${DriveSpace} $9 "/D=F /S=M" $R0
 ${If} $R0 > $R1
 StrCpy $R1 $R0
 StrCpy $R2 $9
 ${EndIf}
 Push $0
FunctionEnd

name "最大剩余空间"
OutFile "maxfreespace.exe"
!include LogicLib.nsh
!include "FileFunc.nsh"
!insertmacro GetDrives
!insertmacro DriveSpace
Section ""
SectionEnd
Var myno1
;Var myno2
Var Drivelabel
Function .onInit
 ${DriveSpace} "C:" "/D=F /S=M" $R0
 StrCpy $myno1 $R0 ;初始化临时变量
 ${GetDrives} "HDD+FDD" "GetDrives_L"
MessageBox MB_OK "最大剩余空间的是盘符$Drivelabel , 空间 $myno1 MB"
FunctionEnd
Function GetDrives_L
${DriveSpace} "$9" "/D=F /S=M" $R0
Push $0
IntCmp $myno1 0 done done +1
IntCmp $R0 $myno1 +1 +3 +1
StrCpy $Drivelabel $9
StrCpy $myno1 $R0
done:
FunctionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » NSIS获取最大容量盘符和最大剩余空间

您必须 登录 才能发表评论!