Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips


#140: How can I define a custom icon for some folder?

In MS Windows you can define any custom icon for desired folder instead default icon (yellow folder picture). Also you can define own string description which will be displayed in Explorer application.

To do it is very easy task:
1. you must create a desktop.ini file with special structure:
[.ShellClassInfo]
IconFile=yourFileWithIcon.ico
IconIndex=0
InfoTip=your description text

2. you must set a System flag to attributes of your folder

A first part is solved in Delphi in a few lines of code:

with TINIFile.Create(yourFolderName + '\desktop.ini') do
  try
    WriteString('.ShellClassInfo', 'IconFile', 'yourFileWithIco.ico');
    WriteString('.ShellClassInfo', 'IconIndex', '0'); //icon index
    WriteString('.ShellClassInfo', 'InfoTip', 'your description text');
    {flush a buffered INI-file to disk}
    UpdateFile; 
  finally
    Free
  end;

A second (to set a system attribute) is not hard too:
SetFileAttributes(PChar(yourFolderName), FILE_ATTRIBUTE_SYSTEM);


Published: May 20, 2002

See also
 
Viewer for TNEF-files (winmail.dat)
dBase Viewer
ExcelFile Viewer
Paradox ActiveX
Protected Storage Viewer
DBLoad
Excel Reader (dll)
ABA Database Convert
ABA Document Convert
Excel Web-stream
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2017, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising