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.
  • 相关阅读:
    pyqt5开发之俄罗斯方块
    Tkenter之API测试系统界面设计
    Python的标准GUI:Tkinter的组件
    Python单元测试框架——unittest
    【Android】自定义ListView的Adapter报空指针异常解决方法
    5、使用Libgdx设计一个简单的游戏------雨滴
    4.6、Libgdx线程介绍
    4.5、Libgdx运行日志管理
    4.4、Libgdx使用方法查询运行环境相关属性
    4.3、Libgdx启动类和配置
  • 原文地址:https://www.cnblogs.com/zhaoshujie/p/9594848.html
Copyright © 2011-2022 走看看