How do you get the Special Folders Directories from the Windows registry ?
Delphi October 16th, 2006Use the following function to return them. A quck adaption and you should be able to set them as well. For more values to pass into the function check the current contents of the registry key.
function GetSpecialDir(ValueName : string): String;
// gets the path to a windows special folder and ensures the trailing backslash is on the path.
// Some Valid ValueNames are
// ‘Personal’ - My Documents
// ‘Desktop’ - User’s Desktop
// ‘Favorites’ - The User Favorites store
var
Reg: TRegistry;
begin
result := ”;
Reg := TRegistry.Create;
try
Reg.RootKey := HKey_Current_User;
if Reg.OpenKeyReadOnly(’\Software\Microsoft\Windows\CurrentVersion\Explo
rer\Shell Folders’) then
result := IncludeTrailingPathDelimiter(Reg.ReadString(ValueName));
finally
Reg.Free;
end;
end;

Recent Comments