gpt4 book ai didi

inno-setup - Inno Setup [Code] 部分变量到 [Registry]

转载 作者:行者123 更新时间:2023-12-01 00:58:47 25 4
gpt4 key购买 nike

我有 Inno Setup 的问题。

我在 [Code] 中使用分辨率检测脚本部分从这里:
INNO Setup: How to get the primary monitor's resolution?

现在我想放 xresyres值为 [Registry]我的安装程序的部分看起来像这样。

Root: HKCU; Subkey: "Software\MyApp\Settings"; Flags: uninsdeletekey; ValueType: dword; \
ValueName: "ScreenWidth"; ValueData: "XRES"
Root: HKCU; Subkey: "Software\MyApp\Settings"; Flags: uninsdeletekey; ValueType: dword; \
ValueName: "ScreenHeight"; ValueData: "YRES"

我试过这个方法 How to use a Pascal variable in Inno Setup? ,但我无法让它工作。我尝试过自己解决问题很多次,但我放弃了......

有人可以帮助我并解释如何做到这一点吗?
我是 Inno Setup 的新手,尤其是 Pascal。

最佳答案

一种方法可以是写一个 scripted constant 两个维度的函数并通过传递的参数返回水平或垂直分辨率。其余的是 Inno Setup 引擎:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Registry]
; the GetResolution function used in the following {code:...} scripted constants
; takes as parameter X to retrieve horizontal resolution, Y to retrieve vertical
Root: HKCU; Subkey: "Software\MyApp\Settings"; Flags: uninsdeletekey; ValueType: dword; \
ValueName: "ScreenWidth"; ValueData: "{code:GetResolution|X}"
Root: HKCU; Subkey: "Software\MyApp\Settings"; Flags: uninsdeletekey; ValueType: dword; \
ValueName: "ScreenHeight"; ValueData: "{code:GetResolution|Y}"

[Code]
function GetSystemMetrics(nIndex: Integer): Integer;
external 'GetSystemMetrics@user32.dll stdcall';

const
SM_CXSCREEN = 0;
SM_CYSCREEN = 1;

function GetResolution(Param: string): string;
begin
// in the {code:...} constant function call we are passing either
// X or Y char to its parameter (here it is the Param parameter),
// so let's decide which dimension we return by the Param's first
// char (uppercased to allow passing even small x and y)
case UpperCase(Param[1]) of
'X': Result := IntToStr(GetSystemMetrics(SM_CXSCREEN));
'Y': Result := IntToStr(GetSystemMetrics(SM_CYSCREEN));
end;
end;

关于inno-setup - Inno Setup [Code] 部分变量到 [Registry],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25372103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com