我现在是使用以下方法:
var
pidl: pItemIDList;
buffer: array[0..255] of char;
st1: string;
begin
//CSIDL_DESKTOP
SHGetSpecialFolderLocation(Application.Handle,CSIDL_DESKTOP, pidl);
SHGetPathFromIDList(pidl, buffer); //转换成文件系统的路径
Result := strpas(buffer);
end; shellTreeView1.path:=上面那个result 可是这个方法会定位到"D:\Documents and Settings\bits\桌面" 这个真实目录下面去,而不是shelltreeview树的顶级目录 "桌面"。 有时也要定位到“我的文档”,不单是要桌面。 请问该怎么办?谢谢。
var
pidl: pItemIDList;
buffer: array[0..255] of char;
st1: string;
begin
//CSIDL_DESKTOP
SHGetSpecialFolderLocation(Application.Handle,CSIDL_DESKTOP, pidl);
SHGetPathFromIDList(pidl, buffer); //转换成文件系统的路径
Result := strpas(buffer);
end; shellTreeView1.path:=上面那个result 可是这个方法会定位到"D:\Documents and Settings\bits\桌面" 这个真实目录下面去,而不是shelltreeview树的顶级目录 "桌面"。 有时也要定位到“我的文档”,不单是要桌面。 请问该怎么办?谢谢。
设置Path属性只会定位到真实路径中去,要想实现你说的定位可能比较麻烦。
我的电脑:ShellTreeView.Root:='rfMyComputer';
begin
ShellTreeView1.Selected := ShellTreeView1.TopItem;
end;procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
ShellTreeView1.Selected := ShellTreeView1.Items[1];
end;procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
ShellTreeView1.Selected := ShellTreeView1.Items[2];
end;
ShellTreeView1.Path := '::{450D8FBA-AD25-11D0-98A8-0800361B1103}';My Documents
explorer ::{450D8FBA-AD25-11D0-98A8-0800361B1103}Network Neighborhood
explorer ::{208D2C60-3AEA-1069-A2D7-08002B30309D}Recycle Bin
explorer ::{645FF040-5081-101B-9F08-00AA002F954E}My Computer
explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}Control Panel
explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}Dial-Up Networking
explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{992CFFA0-F557-101A-88EC-00DD010CCC48}Printers
explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{2227A280-3AEA-1069-A2DE-08002B30309D}Scheduled Tasks
explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}Fonts
explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{D20EA4E1-3957-11d2-A40B-0C5020524152}