type
TSHSetFolderPath = function(csidl: Integer; hToken: THandle; dwFlags: DWORD; Path: PChar): HRESULT; stdcall;
function SetFolderDir(csidl:Integer; newDir: string): Boolean;
var
hd: Cardinal;
SHSetFolderPath: TSHSetFolderPath;
begin
hd := LoadLibrary('shell32.dll');
Assert(hd <> 0, 'shell32.dll not found ?');
SHSetFolderPath := GetprocAddress(hd, PChar(231)); //ansi version,unicode version is 232
Result:= Succeeded(SHSetFolderPath(csidl, 0 , 0, PChar(newdir)));
FreeLibrary(hd);
TSHSetFolderPath = function(csidl: Integer; hToken: THandle; dwFlags: DWORD; Path: PChar): HRESULT; stdcall;
function SetFolderDir(csidl:Integer; newDir: string): Boolean;
var
hd: Cardinal;
SHSetFolderPath: TSHSetFolderPath;
begin
hd := LoadLibrary('shell32.dll');
Assert(hd <> 0, 'shell32.dll not found ?');
SHSetFolderPath := GetprocAddress(hd, PChar(231)); //ansi version,unicode version is 232
Result:= Succeeded(SHSetFolderPath(csidl, 0 , 0, PChar(newdir)));
FreeLibrary(hd);



