例子:删除空文件夹

优质
小牛编辑
114浏览
2023-12-01
引用 删除空文件夹.nsi 的内容:

SetCompressor /SOLID lzma
SetCompress force
!include "FileFunc.nsh"
!insertmacro Locate
XPStyle on
OutFile "删除空文件夹.exe"
Name ""
Var INI
Page Custom ShowCustom LeaveCustom
Function .onInit
BringToFront
InitPluginsDir
GetTempFileName $INI $PLUGINSDIR
File /oname=$INI "删除空文件夹.ini"
FunctionEnd
Function ShowCustom
InstallOptions::initDialog /NOUNLOAD "$INI"
InstallOptions::show
FunctionEnd
Function LeaveCustom
ReadINIStr $R8 $INI "Field 1" "State"
FunctionEnd
Page instfiles
Section
StrCpy $R2 0
StrCpy $R3 0

loop:
StrCpy $R1 0
${Locate} "$R8" "/L=DE" "Example4"
IntOp $R3 $R3 + 1
IntOp $R2 $R2 + $R1
StrCmp $R0 StopLocate +2
StrCmp $R1 0 0 loop

IfErrors 0 +2
MessageBox MB_OK 'error' IDOK +2
MessageBox MB_OK '$R2 directories were removed$\n$R3 loops'
SectionEnd

Function Example4
SetOverwrite try
RMDir $R9
IfErrors +3
IntOp $R1 $R1 + 1
goto end
StrCpy $R0 StopLocate
end:
Push $R0
FunctionEnd

引用 删除空文件夹.ini 的内容:

; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=2

[Field 1]
Type=DirRequest
Left=5
Right=-5
Top=24
Bottom=36

[Field 2]
Type=Label
Text=Դ:
Left=2
Right=89
Top=4
Bottom=14