zoukankan      html  css  js  c++  java
  • 通过读文件方式获得收藏夹中URL

    1. {*******************************************************}
    2. {                                                       }
    3. {       通过读文件方式获得收藏夹中URL                   }
    4. {                                                       }
    5. {       版权所有 (C) 2008 QQ:3150379                   }
    6. {                                                       }
    7. {*******************************************************}
    8. unit Unit1;
    9. interface
    10. uses
    11.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    12.   Dialogs, StdCtrls, IniFiles, ShlObj;
    13. type
    14.   TForm1 = class(TForm)
    15.     btn1: TButton;
    16.     Memo1: TMemo;
    17.     procedure btn1Click(Sender: TObject);
    18.   private
    19.   public
    20.     { Public declarations }
    21.   end;
    22. var
    23.   Form1: TForm1;
    24. implementation
    25. {$R *.dfm}
    26. { TForm1 }
    27. //------------------------------------------------------------------------------
    28. // 通过读文件方式获得收藏夹中URL
    29. //------------------------------------------------------------------------------
    30. procedure TForm1.btn1Click(Sender: TObject);
    31.   function GetFavoritesUrl(FavoritesFile: string): string;
    32.   var
    33.     MyIniFile: TInifile;
    34.   begin
    35.     MyIniFile := TInifile.Create(FavoritesFile);
    36.     try
    37.       Result := MyIniFile.ReadString('InternetShortcut''URL''');
    38.     finally
    39.       MyIniFile.Free;
    40.     end;
    41.   end;
    42. var
    43.   Search: TSearchRec;
    44.   pidl: PItemIDList;
    45.   FavPath: array[0..MAX_PATH] of char;
    46.   FavoritesPath: string;
    47.   i, j: Integer;
    48. begin
    49.   SHGetSpecialFolderLocation(Handle, CSIDL_FAVORITES, pidl);
    50.   SHGetPathFromIDList(pidl, @FavPath);
    51.   FavoritesPath := Format('%s/', [FavPath]);
    52.   Memo1.Clear;
    53.   with Search, Memo1.Lines do
    54.   begin
    55.     i := FindFirst(FavoritesPath + '*.url'0, Search);
    56.     j := 1;
    57.     while i = 0 do
    58.     begin
    59.       if (Search.Name <> '.'and (Search.Name <> '..'then
    60.       begin
    61.         Add(IntToStr(j) + '、' + Name);
    62.         Add('    ' + GetFavoritesUrl(FavoritesPath + Name));
    63.         SetLength(Name, Length(Name) - 4);
    64.         i := FindNext(Search);
    65.         j := j + 1;
    66.       end;
    67.     end;
    68.   end;
    69. end;
    70. end.
  • 相关阅读:
    移动 Web 开发技巧
    判断手机是苹果还是安卓,并且判断安卓的高低版本
    JavaScript判断移动端及pc端访问不同的网站
    input实时监控和获取焦点的问题,oninput,ononfocus
    几个CSS3动画
    canvas加载进度条
    animation动画兼容所有手机
    背景渐变,兼容所有手机端
    文字动画和文字镂空
    前端面试题
  • 原文地址:https://www.cnblogs.com/zhaoshujie/p/9594848.html
Copyright © 2011-2022 走看看