Title: How to create a directory with a specific icon/comment
Question: How to create a directory with a specific icon
Answer:
Works in Windows 2000\XP
The following example create the directory c:\DelphiDir with lock icon, then set the read only attribute
procedure TForm1.Button1Click(Sender: TObject);
var
iniFile : TStrings ;
begin
CreateDir('c:\DelphiDir') ;
iniFile := TStringList.Create;
iniFile.Add('[.ShellClassInfo]') ;
iniFile.Add('IconFile='+
GetEnvironmentVariable('windir')+'\system32\SHELL32.DLL') ;
iniFile.Add('IconIndex=47') ;
iniFile.add('InfoTip=This is a locked folder') ;
iniFile.SaveToFile('c:\DelphiDir\desktop.ini');
SysUtils.FileSetAttr('c:\DelphiDir',SysUtils.faReadOnly) ;
SysUtils.FileSetAttr('c:\DelphiDir\desktop.ini',
SysUtils.faSysFile or SysUtils.faHidden) ;
iniFile.Free ;
end ;