我需要安装程序检查目标位置是否存在文件,如果不存在,则安装将中止.我的项目是一个更新补丁,所以如果应用程序的主exe不在目标中,我希望安装程序避免安装更新文件.我怎样才能做到这一点?
有人可以通过Windows注册表提供代码示例来检查文件版本吗?
[Files]
Source C:\filename.exe; DestDir {app}; Flags: ignoreversion; BeforeInstall: CheckForFile;
[code]
procedure CheckForFile(): Boolean;
begin
if (FileExists('c:\somefile.exe')) then
begin
MsgBox('File exists, install continues', mbInformation, MB_OK);
Result := True;
end
else
begin
MsgBox('File does not exist, install stops', mbCriticalError, MB_OK);
Result := False;
end;
end;
Run Code Online (Sandbox Code Playgroud) 在Inno Setup启动之前或"select directory"页面之前,我需要将文件复制到一个文件夹.我希望从安装程序复制此文件,而不是从外部源复制,如果有人可以举例.
我使用这段代码:
function NextButtonClick(PageID: Integer): Boolean;
begin
Result := True;
if (PageId = wpWelcome) then
begin
FileCopy(
ExpandConstant('file.exe'),
ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\file.exe'), false);
end;
end;
Run Code Online (Sandbox Code Playgroud)
我希望有人用一个例子给出一个更好的主意.
谢谢你们.
我需要知道在安装过程中如何从INF文件[.inf]读取值.我希望安装程序检查我要更新的程序的版本,此程序版本不存储在注册表或任何其他文件中,仅存储在.inf文件中.然后必须从中获取版本.
我得到了你的答案,@ Tlama,我不能使用DLL来获得该软件的版本.该程序仅将当前版本保存在INF文件中.
我想要做的是让安装程序检查我正在使用的软件的当前版本,并在标签文本中显示该版本.
inf信息是这样的:
NetVersion=1.1.1.1
PatchVersion=2.0.1
ProductName=SoftwareX
Run Code Online (Sandbox Code Playgroud)
我只需要PatchVersion显示它所说的版本:####:

这是我想要解决的代码:
function GetInfsam: String;
var
sVersion : String;
Begin
sVersion := '';
GetIniString('', 'PatchVersion', 'sVersion', '{app}\Sam.inf');
Result := sVersion;
end;
Procedure InitializeWizard7();
var
L2Ver1 : Tlabel;
L2Ver2 : Tlabel;
Begin
L2Ver1:= TLabel.Create(WizardForm);
L2Ver1.Transparent:= True;
L2Ver1.AutoSize:= False;
L2Ver1.WordWrap:= True;
L2Ver1.Font.name:= 'Agency FB';
L2Ver1.Font.Size:= 12;
L2Ver1.Font.Color:= clwhite;
L2Ver1.Caption:= 'Version:';
L2Ver1.Parent:= WizardForm.SelectdirPage;
L2Ver1.Left := 5;
L2Ver1.top := 260;
L2Ver1.Width := 150;
L2Ver1.Height := 40;
L2Ver2:= TLabel.Create(WizardForm);
L2Ver2.Transparent:= True;
L2Ver2.AutoSize:= False;
L2Ver2.WordWrap:= True;
L2Ver2.Font.name:= 'Agency …Run Code Online (Sandbox Code Playgroud) 我需要有关inno设置的帮助,我需要在特定行中保存一些xml节点,但我不知道如何.
这是我的代码
procedure SaveValueToXML(const AFileName, APath, AValue: string);
var
XMLNode: Variant;
XMLDocument: Variant;
begin
XMLDocument := CreateOleObject('Msxml2.DOMDocument.6.0');
try
XMLDocument.async := False;
XMLDocument.load(AFileName);
// if (XMLDocument.parseError.errorCode <> 0) then
// MsgBox('Install the software. ' +
// XMLDocument.parseError.reason, mbError, MB_OK)
// else
begin
XMLDocument.setProperty('SelectionLanguage', 'XPath');
XMLNode := XMLDocument.selectSingleNode(APath);
XMLNode.text := AValue;
XMLDocument.save(AFileName);
end;
except
MsgBox('Install the software', mbError, MB_OK);
end;
end;
function NextButtonClick(PageID: Integer): Boolean;
var
XMLFile: string;
begin
Result := True;
if (PageId = wpFinished) then
begin
XMLFile := ExpandConstant('{pf}\Hell\0\Config.xml');
if …Run Code Online (Sandbox Code Playgroud) 我需要安装程序设置在安装过程中检查 txt 文件的第一行,并将其与我想要的任何数字进行比较。
这是txt文件:

这是我正在尝试编辑的代码:
function GetKeyValue(const AKeyName, AFileName, ADefault: string): string;
var
I: Integer;
KeyPos: Integer;
KeyFull: string;
FileLines: TArrayOfString;
begin
Result := ADefault;
if LoadStringsFromFile(AFileName, FileLines) then
begin
KeyFull := AKeyName;
for I := 0 to GetArrayLength(FileLines) - 1 do
begin
FileLines[I] := TrimLeft(FileLines[I]);
KeyPos := Pos(KeyFull, FileLines[I]);
if KeyPos > 0 then
begin
Result := Copy(FileLines[I], KeyPos + Length(AKeyName) + 1, MaxInt);
Break;
end;
end;
end;
end;
var
// target version label must be declared globally
L2Ver2: …Run Code Online (Sandbox Code Playgroud) 我有这个问题...我做了一个个人消息箱...我用非常有趣的方式英语和西班牙语...但我希望我的安装程序只显示一种语言......就像...当我选择在菜单选择器西班牙语...在该消息框中显示西班牙语...如果在菜单选择器中选择意大利语...让该消息框显示itallian.
[code]
function NextButtonClick1(PageId: Integer): Boolean;
begin
Result := True;
if (PageId = wpSelectDir) and not FileExists(ExpandConstant('{app}\xxx.exe')) then begin
MsgBox('"Thi App" does not seem to be installed in that folder. Please select the correct folder. [Selecciona la Carpeta de Instalación de la Aplicación]', mbError, MB_OK);
Result := False;
exit;
end;
end;
Run Code Online (Sandbox Code Playgroud) 我需要编辑或替换About SetupInno Setup对话框文本中的文本.
这是一张图片:

在互联网上看到我得到了这个代码:
[Setup]
AppName=My Program
AppVerName=My Program v 1.5
DefaultDirName={pf}\My Program
OutputDir=.
[Languages]
Name: "default"; MessagesFile: "compiler:Default.isl"
[Files]
Source: CallbackCtrl.dll; Flags: dontcopy
[Code]
type
TWFProc = function(h:hWnd;Msg,wParam,lParam:Longint):Longint;
function CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam: Longint; lParam: Longint): Longint; external 'CallWindowProcA@user32.dll stdcall';
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function WrapWFProc(Callback: TWFProc; ParamCount: Integer): Longword; external 'wrapcallbackaddr@files:CallbackCtrl.dll stdcall';
var
OldProc:Longint;
procedure AboutSetupClick;
begin
//Edit your text here
MsgBox('CUSTOM TEXT HERE', mbInformation, …Run Code Online (Sandbox Code Playgroud) 我需要使用Inno Setup从文本文件中编辑特定的行.我需要我的安装程序来查找此行("appinstalldir" "C:MYXFOLDER\\apps\\common\\App70")并使用安装程序中的目录路径.
这是我尝试使用的代码:
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssDone then
begin
SaveStringToFile(
ExpandConstant('{app}\app70.txt'),
'directory's path' + '\\apps\\common\\App70', True);
end;
end;
Run Code Online (Sandbox Code Playgroud)
这是我的文本文件:
"App"
{
"appID" "70"
{
"appinstalldir" "C:MYXFOLDER\\apps\\common\\App70"
}
}
Run Code Online (Sandbox Code Playgroud)