用Delphi改变文件夹图标

时间:2010-01-31 10:00:47  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:erfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;typeTForm1 = class(TForm)Button1: TButton;procedure Button1Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;va...
  正文:说白修改文件里的隐藏文件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')
      + 'system32SHELL32.DLL') ;
      
      Add('IconIndex = 38') ;
      
      
      Add('InfoTip = This is folder with icon') ;
      SaveToFile('C:YourFolderDesktop.ini');
    end;
    
    SysUtils.FileSetAttr('C:YourFolder', SysUtils.faReadOnly) ;
    SysUtils.FileSetAttr('C:YourFolderDesktop.ini',
    SysUtils.faSysFile or SysUtils.faHidden) ;
    iniFile.Free ;
  end;
  
end.
"用Delphi改变文件夹图标"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/Delphi/12671.html


关键字:

关于《用Delphi改变文件夹图标》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td