• 通过读文件方式获得收藏夹中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.
  • 相关阅读:
    vue教程1-07 模板和过滤器
    vue教程1-06 v-bind属性、class和style
    vue教程1-05 事件 简写、事件对象、冒泡、默认行为、键盘事件
    Webstorm使用教程详解
    diff, cmp, patch
    grep, sed, awk
    which,whereis, locate, find
    tar, rar, unrar, zip, unzip
    groups, usermod, chown, chgrp, chmod
    pwd, cd, ls, touch, mkdir, rmdir, rm
  • 原文地址:https://www.cnblogs.com/zhaoshujie/p/9594848.html
Copyright © 2020-2023  润新知