获取IE收藏夹内容
Helmut Dollinger
摘 要:如何从MSIE递归的读取保存的URL!
关键字:Internet-Explorer 收藏夹
类 别:网络
中文开发在线原创作品,未经允许,严禁任何形式的转载
uses shlobj;
...
function GetIEFavorites(const favpath: string):TStrings;
var searchrec:TSearchrec;
str:TStrings;
path,dir,filename:String;
Buffer: array[0..2047] of Char;
found:Integer;
begin
str:=TStringList.Create;
//取在favourites 路径下的所有名字
path:=FavPath+'/*.url';
dir:=ExtractFilepath(path);
found:=FindFirst(path,faAnyFile,searchrec);
while found = 0 do
begin
//从files变量读URLs
SetString(filename, Buffer,
GetPrivateProfileString('InternetShortcut',
PChar('URL'), NIL, Buffer, SizeOf(Buffer),
PChar(dir+searchrec.Name)));
str.Add(filename);
found := FindNext(searchrec);
end;
found:=FindFirst(dir+'/*.*',faAnyFile,searchrec);
while found=0 do
begin
if ((searchrec.Attr and faDirectory) > 0) and
(searchrec.Name[1]<>'.') then
str.AddStrings(GetIEFavorites(dir+'/'+searchrec.name));
found := FindNext(searchrec);
end;
FindClose(searchrec);
Result:=str;
end;
procedure TForm1.Button1Click(Sender: TObject);
var pidl: PItemIDList;
FavPath: array[0..MAX_PATH] of char;
begin
//获取收藏夹
SHGetSpecialFolderLocation(Handle, CSIDL_FAVORITES, pidl);
SHGetPathFromIDList(pidl, favpath);
ListBox1.Items:=GetIEFavorites(StrPas(FavPath));
end;
投稿人:CoDelphi.com 投稿日期:2001-5-19 14:57:00