Scalabium Software

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


#14: How can I get a system icons?

If you want to fill in TImageList the system icon list, then you can write the next:

var FileInfo: TSHFileInfo;
begin
  {to get a small icons}
  imgListSysSmall := TImageList.Create(nil);
  with imgListSysSmall do
  begin
    Handle := SHGetFileInfo('', 0, FileInfo, SizeOf(TSHFileInfo),
      SHGFI_SMALLICON or SHGFI_SYSICONINDEX );
   ShareImages := True;
  end;

  {to get a small icons}
  imgListSysLarge := TImageList.Create(nil);
  with imgListSysLarge do
  begin
    Handle := SHGetFileInfo('', 0, FileInfo, SizeOf(TSHFileInfo),
      SHGFI_LARGEICON or SHGFI_SYSICONINDEX );
   ShareImages := True;
  end;
end;

Also if you want to get a "My Computer" icon, you must use the next
function:

var FileInfo: TSHFileInfo;
     PIDL: PItemIDList;
begin
  SHGetSpecialFolderLocation(Application.Handle, CSIDL_DRIVES, PIDL);
  if SHGetFileInfo(PChar(PIDL), 0, FileInfo, SizeOf(TSHFileInfo),
     SHGFI_PIDL or SHGFI_SYSICONINDEX ) <> 0 then
        Result := FileInfo.iIcon;
end;

In this function you can use the constants from shlobj.pas:

  CSIDL_DESKTOP                       = $0000; 
  CSIDL_PROGRAMS                      = $0002; 
  CSIDL_CONTROLS                      = $0003; 
  CSIDL_PRINTERS                      = $0004; 
  CSIDL_PERSONAL                      = $0005; 
  CSIDL_FAVORITES                     = $0006; 
  CSIDL_STARTUP                       = $0007; 
  CSIDL_RECENT                        = $0008; 
  CSIDL_SENDTO                        = $0009; 
  CSIDL_BITBUCKET                     = $000a; 
  CSIDL_STARTMENU                     = $000b; 
  CSIDL_DESKTOPDIRECTORY              = $0010; 
  CSIDL_DRIVES                        = $0011; 
  CSIDL_NETWORK                       = $0012; 
  CSIDL_NETHOOD                       = $0013; 
  CSIDL_FONTS                         = $0014; 
  CSIDL_TEMPLATES                     = $0015; 
  CSIDL_COMMON_STARTMENU              = $0016; 
  CSIDL_COMMON_PROGRAMS               = $0017; 
  CSIDL_COMMON_STARTUP                = $0018; 
  CSIDL_COMMON_DESKTOPDIRECTORY       = $0019; 
  CSIDL_APPDATA                       = $001A; 
  CSIDL_PRINTHOOD                     = $001B;


Published: August 16, 1999

See also
 
ABA Spreadsheet Convert
ExcelFile Viewer
Paradox Viewer
Paradox Password Recovery
Viewer for MS Outlook Messages
SMImport suite
SMMsg suite
Excel Reader (dll)
dBase Viewer
ABA Picture Convert
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

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

SMReport Autogenerated