//大家不要怪我抢分了:) 自动识别WINDOWS版本<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;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>label Write;<br>var<br>Favorites:String;<br>Search:TSearchRec;<br>begin<br>{9X}<br>Favorites:=GetFavoritesPath;<br>{NT/2K}<br>if copy(Favorites,1,1)='%' then Favorites:=GetFav2KDir;<br><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.GetFav2KDir: string;<br>var<br> sysDir: array[0..250] of char;<br> pszLoginid: array[0 .. 199] of char;<br> nSize: Cardinal;<br>begin<br> nSize := 200;<br> if WNetGetUser(nil, pszLoginid, nSize) = NO_ERROR then<br> begin<br> GetSystemDirectory(sysDir, 250);<br> result:=Copy(StrPas(sysDir),1,3)+'Documents and Settings/'+StrPas(pszLoginid)+'/Favorites/';<br> end;<br>end;