1、背景
我需要找出字符串是否包含一个给定的子字符串. 例如,如果我正在这样寻找一个字符串中的子字符串ABC:S := 'ABC String'; 我应该得到结果为真,而对于以下字符串我应该得到结果False:S := 'DEF String'; 如何检查一个字符串是否包含InnoSetup中的子字符串?
2、办法
Innosetup有一个Pos()函数,与Delphi完全一样.请参见
https://jrsoftware.org/ishelp/index.php?topic=scriptfunctions的支持功能参考
Prototype:
function Pos(SubStr, S: String): Integer;
Description:
Searches for Substr within S and returns an integer value that is the index of the first character of Substr within S.
If Substr is not found, Pos returns zero. The Pos function is case-sensitive.
实现
Pos('2019', RegeditValue222333);
if MsgBox('检测到WPS版本过低或没有安装,是否立即下载最新版?', mbConfirmation, MB_YESNO) = idYes then
begin
ShellExec('open', 'https://official-package.wpscdn.cn/wps/download/WPS_Setup_12302.exe', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode11111);
// MsgBox('请安装好指定的WPS软件后,再运行本安装包程序!',mbInformation,MB_OK);
Result := false;
Istoken2019 := false;
end
else
begin
MsgBox('不下载指定的WPS软件,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
Result := false;
Istoken2019 := false;
end
end;
if Istoken2019 then begin
if RegQueryStringValue(GetHKLM, 'SOFTWARE\Kingsoft\Office\6.0\Common','DisplayName',RegeditValue222333) then begin
// MsgBox(RegeditValue222333, mbInformation, MB_OK);
// MsgBox(IntToStr(Pos('2019', RegeditValue222333)), mbInformation, MB_OK);
ResultCode2222333 := Pos('2019', RegeditValue222333);
if(ResultCode2222333>0) then
begin
技术群:添加小编微信并备注进群
小编微信:mm1552923 公众号:dotNet编程大全