Reputation: 3
How is possible to add two subfolders behind a path read from registry?
[Code]
function GetDirName(Value: string): string;
var
InstallPath: string;
begin
Result := 'C:\Program Files (x86)\myapp\subfolder1\subfolder2';
if RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\myapp', 'RootPath', InstallPath) then
Result := InstallPath
else
// query the second registry value; if it succeeds, return the obtained value
if RegQueryStringValue(HKLM, '\SOFTWARE\myapp', 'RootPath', InstallPath) then
Result := InstallPath;
end;
When I got the destination from register I need to add behind it \subfolder1\subfolder2
and complete destination get to function GetDirName
.
Can someone guide me?
Thanks a lot.
Upvotes: 0
Views: 95
Reputation: 202642
Just concatenate the two strings at the end of the GetDirName
function:
function GetDirName(Value: string): string;
var
InstallPath: string;
begin
// expand path to the 32-bit Program Files folder with appended 'myapp' subfolder
Result := ExpandConstant('{pf32}\myapp');
// query value from 64-bit registry node (notice the used HKLM64 root key)
if RegQueryStringValue(HKLM64, 'SOFTWARE\myapp', 'RootPath', InstallPath) or
// query value from 32-bit registry node (notice the used HKLM32 root key)
RegQueryStringValue(HKLM32, 'SOFTWARE\myapp', 'RootPath', InstallPath) then
begin
Result := InstallPath;
end;
// ensure the path will have backslash and append the final subdirectory string
Result := AddBackslash(Result) + 'subfolder1\subfolder2';
end;
Upvotes: 1