IE收藏夹的导入和导出如何实现?(100分)

  • 主题发起人 主题发起人 myevin
  • 开始时间 开始时间
M

myevin

Unregistered / Unconfirmed
GUEST, unregistred user!
请问,IE收藏夹的导入和导出如何实现?用什么api函数可以快捷的实现呢?
 
IE收藏夹<br>里的文件就是一个标准的INI文件,<br>你可以用标准的TIniFile函数来进行读取和保存
 
我也不知
 
我知道.url文件实际就是ini文件,ie在导出和导入收藏佳时<br>是把目录转换为htm文件,我想问一下是否有api函数可以直接实现?
 
学习procedure TForm1.ToolButton1Click(Sender: TObject);<br>label<br>Write;<br>var<br>Favorites:String;<br>Search:TSearchRec;<br>begin<br>Favorites:=GetFavoritesPath;<br>if Favorites='' then<br>begin<br>MessageBox(Handle,'访问收藏夹主键错误!','提示信息',MB_OK);<br>exit;<br>end;<br>Memo1.Clear;<br>with Search,Memo1.Lines do<br>begin<br>if FindFirst(Favorites+'*.url',0,Search)=0 then<br>begin<br>Write:<br>Add(GetFavoritesUrl(Favorites+Name));<br>SetLength(Name,Length(Name)-4);<br>Add(Name);<br>if FindNext(Search)=0 then<br>goto Write;<br>end;<br>end;<br>end;<br><br>function TForm1.GetFavoritesPath:String;<br>var<br>reg:TRegistry;<br>begin<br>Result:='';<br>reg:=TRegistry.Create;<br>with reg do<br>begin<br>RootKey:=HKEY_USERS;<br>if OpenKey('.DEFAULT/Software/Microsoft/Windows/CurrentVersion/Explorer/User Shell Folders',false)=true then<br>Result:=ReadString('Favorites')+'/';<br>CloseKey;<br>Free;<br>end;<br>end;<br><br>{function TForm1.GetFavoritesUrl(FavoritesFile: String): String;<br>begin<br>with TIniFile.Create(FavoritesFile)do<br>begin<br>Result:=ReadString('InternetShortcut','URL','');<br>Free;<br>end;<br>end;}<br><br>function TForm1.GetFavoritesUrl(FavoritesFile: String): String;<br>var<br>i:integer;<br>begin<br>Result:='';<br>with TStringList.Create do<br>begin<br>LoadFromFile(FavoritesFile);<br>i:=IndexOf('[InternetShortcut]');<br>if i=-1 then<br>exit;<br>Result:=Strings[i+1];<br>System.Delete(Result,1,4);<br>Free;<br>end;<br>end; &nbsp;<br>
 
谢谢各位,我已经在MSDN上找到了解决问题的方法。<br><br>首先需要uses SHDocVw, ComObj;<br><br>具体程序如下:<br>const<br>&nbsp; &nbsp; &nbsp; &nbsp; CLSID_ShellUIHelper : TGUID = '{64AB4BB7-111E-11D1-8F79-00C04FC2FBE1}';<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; &nbsp; &nbsp; &nbsp; ShellUIHelper: ISHellUIHelper;<br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp; ShellUIHelper := CreateComObject(CLSID_SHELLUIHELPER) as IShellUIHelper;<br>&nbsp; &nbsp; &nbsp; &nbsp; //导入<br>&nbsp; &nbsp; &nbsp; &nbsp; ShellUIHelper.ImportExportFavorites(True, PChar('c:/my.htm'));<br>&nbsp; &nbsp; &nbsp; &nbsp; //导出<br>&nbsp; &nbsp; &nbsp; &nbsp; ShellUIHelper.ImportExportFavorites(False, PChar('c:/my.htm'));<br>end;<br><br><br>MSDN上的解释为:<br>IShellUIHelper::ImportExportFavorites Method<br><br>--------------------------------------------------------------------------------<br><br>Handles the importing and exporting of Microsoft&amp;reg; Internet Explorer favorites.<br><br>Syntax<br><br>HRESULT ImportExportFavorites(<br>&nbsp; &nbsp; VARIANT_BOOL fImport,<br>&nbsp; &nbsp; BSTR strImpExpPath<br>);<br><br>Parameters<br><br>fImport <br>VARIANT_BOOL value that specifies if this is an import or export operation. VARIANT_TRUE indicates an import operation, while VARIANT_FALSE indicates an export operation. <br>strImpExpPath <br>String value that contains the path to the location of the import or export file. <br>Return Value<br><br>Returns S_OK if successful, or an error value otherwise.<br><br>Remarks<br><br>Favorites that reference local files are not created during import. They are filtered out without comment and the program continues.<br><br>The ImportExportFavorites method imports favorites from or exports favorites to an HTML page in the Netscape bookmark format.<br><br><br>
 

Similar threads

回复
0
查看
978
不得闲
S
回复
0
查看
835
SUNSTONE的Delphi笔记
S
S
回复
0
查看
765
SUNSTONE的Delphi笔记
S
后退
顶部