utton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function Tform1.GetIEFavourites(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;
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(''''+copy(searchrec.Name,1,length(searchrec.Name)-4)+''''+''
'');
found := FindNext(searchrec);
end;
found := FindFirst(dir + ''\*.*'', faAnyFile, searchrec);
while found = 0 do
begin
if ((searchrec.Attr and faDirectory) > 0) and (searchrec.Name <> ''.'') then
begin
str.add(''
'');
str.add(searchrec.name+''
'');
str.AddStrings(GetIEFavourites(dir + ''\'' + searchrec.Name));
end;
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);
memo1.Lines.Add('''');
memo1.Lines.Add('''');
memo1.Lines.Add('''');
memo1.Lines.Add(''我的收藏夹'');
memo1.Lines.Add(''--------------------------------------------------------------------------------'');
memo1.Lines.add(GetIEFavourites(StrPas(FavPath)).gettext);
memo1.Lines.Add('''');
button2.Enabled:=true;
showmessage(''代码生成完成!'');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Reg: TRegistry;
deskpath:string;
begin
//取得桌面路径
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey(''Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'', false) then
deskpath:=Reg.readString(''Desktop'');
finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
//设为首页
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey(''Software\Microsoft\Internet Explorer\Main'', false) then
Reg.writeString(''Start Page'',deskpath+''\我的收藏夹.htm'');
finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
memo1.Lines.SaveToFile(deskpath+''\我的收藏夹.htm'');
showmessage(''文件导出完成!'');
end;
end.