mobile
23-04-2010, 10:19 AM
uses SHFolder;
function GetSpecialFolderPath(folder : integer) : string;
const
SHGFP_TYPE_CURRENT = 0;
var
path: array [0..MAX_PATH] of char;
begin
if SUCCEEDED(SHGetFolderPath(0,folder,0,SHGFP_TYPE_CU RRENT,@path[0])) then
Result := path
else
Result := '';
end;
//RadioGroup1 OnClick
procedure TForm1.RadioGroup1Click(Sender: TObject) ;
var
index : integer;
specialFolder : integer;
begin
if RadioGroup1.ItemIndex = -1 then Exit;
index := RadioGroup1.ItemIndex;
case index of
//[Current User]\My Documents
0: specialFolder := CSIDL_PERSONAL;
//All Users\Application Data
1: specialFolder := CSIDL_COMMON_APPDATA;
//[User Specific]\Application Data
2: specialFolder := CSIDL_LOCAL_APPDATA;
//Program Files
3: specialFolder := CSIDL_PROGRAM_FILES;
//All Users\Documents
4: specialFolder := CSIDL_COMMON_DOCUMENTS;
end;
Label1.Caption := GetSpecialFolderPath(specialFolder) ;
end;
function GetSpecialFolderPath(folder : integer) : string;
const
SHGFP_TYPE_CURRENT = 0;
var
path: array [0..MAX_PATH] of char;
begin
if SUCCEEDED(SHGetFolderPath(0,folder,0,SHGFP_TYPE_CU RRENT,@path[0])) then
Result := path
else
Result := '';
end;
//RadioGroup1 OnClick
procedure TForm1.RadioGroup1Click(Sender: TObject) ;
var
index : integer;
specialFolder : integer;
begin
if RadioGroup1.ItemIndex = -1 then Exit;
index := RadioGroup1.ItemIndex;
case index of
//[Current User]\My Documents
0: specialFolder := CSIDL_PERSONAL;
//All Users\Application Data
1: specialFolder := CSIDL_COMMON_APPDATA;
//[User Specific]\Application Data
2: specialFolder := CSIDL_LOCAL_APPDATA;
//Program Files
3: specialFolder := CSIDL_PROGRAM_FILES;
//All Users\Documents
4: specialFolder := CSIDL_COMMON_DOCUMENTS;
end;
Label1.Caption := GetSpecialFolderPath(specialFolder) ;
end;