判断路径中是否存在中文字符范例

!include "MUI2.nsh"
!include "LogicLib.nsh"
!insertmacro MUI_LANGUAGE "SimpChinese"

OutFile "判断路径中是否存在中文字符.exe"
Name "判断路径中是否存在中文字符"
;修改下面的路径为英文试试
InstallDir "$PROGRAMFILES\修改这里为英文试试"
BrandingText "www.yhxs3344.net


Section nsisfans
 !insertmacro MUI_HEADER_TEXT "检测路径" "www.yhxs3344.net"

 Push "$INSTDIR"
 Call IsMultiBytes
 Pop $0
 ${If} $0 = 1
 MessageBox MB_OK "你的路径“$INSTDIR”里包含中文!"
 ${Else}
 MessageBox MB_OK "你的路径正常!"
 ${EndIf}
SectionEnd

Function IsMultiBytes
 Exch $R0
 Push $R1
 Push $R2
 Push $R3
 Push $R4
 StrLen $R1 $R0
 ${For} $R2 0 $R1
 StrCpy $R3 $R0 1 $R2
 System::Call `*(&t1 "$R3")i.R4`
 System::Call `*$R4(&i1.R3)`
 SysTem::Free $R4
 ${If} $R3 > 0x7F
 StrCpy $R0 1
 Goto lab_true
 ${EndIf}
 ${Next}
 StrCpy $R0 0
lab_true:
 Pop $R4
 Pop $R3
 Pop $R2
 Pop $R1
 Exch $R0
FunctionEnd
THE END
喜欢就支持一下吧
点赞7 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容