Title: How to make a folder with icon image
Question: How can I make a folder with icon image?
Answer:
This article shows that how can changing a folder icon.
Sometimes, you can want to change your folder icon. If you want this, then insert the following code into Button1's OnClick event:
I hope this be usefull for someone.
procedure TForm1.Button1Click(Sender: TObject);
var
iniFile : TStrings ;
begin
CreateDir('C:\YourFolder') ;
iniFile := TStringList.Create;
with iniFile do
begin
Add('[.ShellClassInfo]') ;
// if you want to load an icon from a dll - for example, Shell32.dll
Add('IconFile = ' + GetEnvironmentVariable('Windir')
+ '\system32\SHELL32.DLL') ;
Add('IconIndex = 38') ;
// or you can also load from a specific path, for example;
{ Add('IconFile = ' + 'C:\YourIcons\Icons\Sample.ico');
Add('IconIndex = 0') ; }
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;