Pegar lista meus favoritos
Eu peguei um exemplo da internet e não funcionou, acho que tem que declarar alguns itens na USES, alguem poderia me ajudar ou me passar outra rotina, desde já agradeço.
Abaixo a rotina que baixei.
function GetIEFavoritos(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;
//Pega todos os nomes de arquivo no path dos favoritos
path:=FavPath+´\*.url´;
dir:=ExtractFilepath(path);
found:=FindFirst(path,faAnyFile,searchrec);
while found=0 do begin
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(GetIEFavourites(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:= GetIEFavoritos (StrPas(FavPath));
end;
Abaixo a rotina que baixei.
function GetIEFavoritos(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;
//Pega todos os nomes de arquivo no path dos favoritos
path:=FavPath+´\*.url´;
dir:=ExtractFilepath(path);
found:=FindFirst(path,faAnyFile,searchrec);
while found=0 do begin
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(GetIEFavourites(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:= GetIEFavoritos (StrPas(FavPath));
end;
Jcmsistemas
Curtidas 0
Respostas
Massuda
05/01/2005
Eu peguei um exemplo da internet e não funcionou, acho que tem que declarar alguns itens na USES
Inclua [b:09a632763b]SysUtils[/b:09a632763b] e [b:09a632763b]ShlObj[/b:09a632763b] no uses.GOSTEI 0
Tatuweb
05/01/2005
Só mais uma observação:
[b:dc88230caf]str.AddStrings([color=blue:dc88230caf]GetIEFavourites[/color:dc88230caf](dir+´\´+searchrec.name));[/b:dc88230caf]
para
[b:dc88230caf]str.AddStrings([color=blue:dc88230caf]GetIEFavoritos[/color:dc88230caf](dir+´\´+searchrec.name));[/b:dc88230caf]
[b:dc88230caf]str.AddStrings([color=blue:dc88230caf]GetIEFavourites[/color:dc88230caf](dir+´\´+searchrec.name));[/b:dc88230caf]
para
[b:dc88230caf]str.AddStrings([color=blue:dc88230caf]GetIEFavoritos[/color:dc88230caf](dir+´\´+searchrec.name));[/b:dc88230caf]
GOSTEI 0
Jcmsistemas
05/01/2005
obrigado pela ajuda, agora ja esta funcionando a rotina.
GOSTEI 0