Search notes:

desktop.ini

The desktop.ini file can be used to customize some aspects of a folder, for example the icon that's displayed with the folder
In order for the desktop.ini file to have any effect, the folder that contains it needs to have the system attribute set. This attribute can be set on the command line (cmd.exe, PowerShell) with
attrib.exe +s folder-name

Referencing an icon in dll

The following example tries to demonstrate how an icon in a DLL can be referenced:
[.ShellClassInfo]
IconFile=%windir%\System32\imageres.dll
IconIndex=233
InfoTip=Hello World

Referencing local files

It's also possible to reference a bitmap or icon file:
[.ShellClassInfo]
IconFile=32x32.bmp
IconIndex=0

Creating a red directory in PowerShell

Create the directory:
$null = mkdir red-directory
cd            red-directory
Add a .bmp:
add-type -assembly 'System.Drawing'
$bmp_16x16 = new-object Drawing.Bitmap 16, 16

$canvas = [Drawing.Graphics]::FromImage($bmp_16x16);
$brushRect = new-object Drawing.SolidBrush ([Drawing.Color]::FromArgb(255, 255, 0, 0));
$canvas.FillRectangle($brushRect, [Drawing.Rectangle]::FromLTRB(0, 0, 16, 16));

$bmp_16x16.Save("$(get-location)\16x16-red.bmp", [System.Drawing.Imaging.ImageFormat]::Bmp);
create desktop.ini file:
@'
[.ShellClassInfo]
ConfirmFileOp=0
IconFile=16x16-red.bmp
IconIndex=0
InfoTip=This is the info tip
'@ | out-file -encoding utf8 desktop.ini
Set system attribute for directory and desktop.ini:
(get-itemProperty .\desktop.ini  ).attributes += 'system'
(get-itemProperty $pwd           ).attributes += 'system'

Index