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

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
© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容