說白修改文件裡的隱藏文件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;