Inno Setup 注册表获取程序安装路径

来源:互联网 发布:sql查询语句不重复 编辑:程序博客网 时间:2024/05/16 06:16
https://github.com/Palakis/obs-websocket/blob/master/installer/installer.iss
来自这个位置
; Script generated by the Inno Setup Script Wizard.; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!#define MyAppName "MyApp"#define MyAppVersion "1.1"#define MyAppPublisher "rang"#define MyAppExeName "MyApp-setup.exe"[Setup]; NOTE: The value of AppId uniquely identifies this application.; Do not use the same AppId value in installers for other applications.; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)AppId={{BC4AA8B8-8751-4D3F-BC0D-F168710A7114}AppName={#MyAppName}AppVersion={#MyAppVersion};AppVerName={#MyAppName} {#MyAppVersion}AppPublisher={#MyAppPublisher}DefaultDirName={code:GetDirName}DefaultGroupName={#MyAppName}OutputDir=D:\MyAppOutputBaseFilename=MyApp1.1Compression=lzmaSolidCompression=yesDisableDirPage=yes[Languages]Name: "Default"; MessagesFile: "compiler:Default.isl"Name: "english"; MessagesFile: "compiler:Languages\English.isl"Name: "french"; MessagesFile: "compiler:Languages\French.isl"Name: "german"; MessagesFile: "compiler:Languages\German.isl"Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"[Files]Source: "D:\MyApp\MyApp.dll"; DestDir: "{app}"; Flags: ignoreversion; NOTE: Don't use "Flags: ignoreversion" on any shared system files[Code]// credit where it's due :// following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45function GetDirName(Value: string): string;var  InstallPath: string;begin  // initialize default path, which will be returned when the following registry  // key queries fail due to missing keys or for some different reason  Result := '{pf}\obs-studio\obs-plugins\32bit\';  // query the first registry value; if this succeeds, return the obtained value  if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then    Result := InstallPath + '\obs-plugins\32bit\';end;
这里最后的InstallPath是程序安装路径的根目录,我这加后面的就是程序里想要装的地方

0 0