문제 설명
Inno Setup ‑ [code] 내부의 기본 경로 정의 (Inno Setup ‑ Defining a default path inside [code])
내 앱 업데이트가 DefaultDirName으로 이전에 저장된 설치 경로를 검색할 수 있도록 Windows 레지스트리를 읽으려고 합니다.
다음과 같은 함수를 호출해야 하는 곳을 읽었습니다.
DefaultDirName="{code:GetPath}"
문제는 함수가 이전 경로를 찾지 못할 경우를 대비하여 기본 경로를 정의해야 한다는 것입니다. 예를 들어, 'C:\MyPath'. 그래서 저는 이렇게 했습니다:
[Code]
function GetPath(Value: String): String;
var
OrigPath: string;
begin
Result := '{sd}\MyPath';
if RegQueryStringValue(HKCU, 'Software\MyApp', 'PathExec', OrigPath) then
Result := OrigPath;
end;
작동하지 않습니다. 설정을 실행할 때 대상 디렉터리 대화 상자에서 "C:\MyPath"가 아니라 문자 그대로 "C:\PathOfMySetup\{sd}\MyPath"가 표시됩니다.
시스템 드라이브에서 "MyPath"를 생성하려면 첫 번째 "Result := " 줄에 무엇을 써야 하나요?
감사합니다.
참조 솔루션
방법 1:
The constants in Pascal Script are not magically expanded. You have to expand them explicitly using the ExpandConstant
function:
Result := ExpandConstant('{sd}\MyPath');
(by mehrlich、Martin Prikryl)