当前位置:主页>Delphi教程>文章内容
改变文件夹图标
来源: 作者: 发布时间:2007-04-29  
 

说白修改文件里的隐藏文件desktop.ini
下面是源代码
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  iniFile : TStrings ;
begin
  CreateDir('C:\YourFolder') ;
  iniFile := TStringList.Create;
  with iniFile do
  begin
    Add('[.ShellClassInfo]') ;

    Add('IconFile = ' + GetEnvironmentVariable('Windir')
                      + '\system32\SHELL32.DLL') ;

    Add('IconIndex = 38') ;


    Add('InfoTip = This is folder with icon') ;
    SaveToFile('C:\YourFolder\Desktop.ini');
  end;

  SysUtils.FileSetAttr('C:\YourFolder', SysUtils.faReadOnly) ;
  SysUtils.FileSetAttr('C:\YourFolder\Desktop.ini',
                        SysUtils.faSysFile or SysUtils.faHidden) ;
  iniFile.Free ;
end;


end.


 


 
上一篇:我的文章-《剖析Delphi中的构造和析构》   下一篇:将Dcom对象转换成Com+对象的一种办法
 
  相关文章
·我的文章-《剖析Delphi中的构造和析构
·将Dcom对象转换成Com+对象的一种办法
·我的文章-《剖析Delphi中的多态》
·两个delphi下遍历指定目录下指定类型文
·多层数据库开发十四:剖析几个MIDAS示范
·对DBGrid中的列进行显示与否的设置
·多层数据库开发十三:剖析几个数据库应
·将Dcom对象转换成Com+对象的一种办法
·多层数据库开发十二:使用数据控件
·控件style你知我知
·多层数据库开发九:查询数据库
·DELPHI中拖放的操作
 
【关闭窗口】
推荐本站资源
最新文章