Where are the windows system icons located?


Where are the windows system icons located ? - Things likeControl Panel icon, MyComputer/This PC Icon.

How Can I get a picture of those icons programatically.

I am creating my own launcher app with imageless, so that when the user drop an item on one of those imageless a picture of the item is displayed in the same image well.



There is no built in function in Xojo.

Declares can be used, but you will have to code them. See https://msdn.microsoft.com/en-us/library/ms997538.aspx?f=255&MSPPError=-2147217396

They’re stored in DLL, EXE, ICO, ANI, and other files as loadable resources. Here’s a function that takes a FolderItem, an Index, and the size in pixels requested and returns a Picture (or Nil on error):

Function ExtractIcon(Resource as FolderItem, Index As Integer, pixSize As Integer = 32) As Picture
  Declare Function ExtractIconExW Lib "Shell32" (ResourceFile As WString, Index As Integer, largeIco As Ptr,  smallIco As Ptr, Icons As Integer) As Integer
  Declare Function DrawIconEx Lib "User32" (hDC As Integer, xLeft As Integer, yTop As Integer, hIcon As Integer, cxWidth As Integer, cyWidth As Integer, istepIfAniCur As Integer, hbrFlickerFreeDraw As Integer, diFlags As Integer) As Boolean
  Declare Function DestroyIcon Lib "User32" (hIcon As Integer) As Integer
  Const DI_NORMAL = &h3
  Dim icon As Picture = New Picture(pixsize, pixsize, 32)
  icon.Transparent = 1
  Dim largeIco As New MemoryBlock(4)
    Call ExtractIconExW(resource.AbsolutePath, Index, largeIco, Nil, 1)    
    Dim hDC As Integer = icon.Graphics.Handle(icon.Graphics.HandleTypeHDC)
    Call DrawIconEx(hDC, 0, 0, largeIco.Int32Value(0), pixsize, pixsize, 0, 0, DI_NORMAL)
    icon = Nil
    Call DestroyIcon(largeIco.Int32Value(0))
  End Try
  Return icon
End Function

You can use a tool like IconsExtract to examine the icon entries in a file.

Thanks Andrew,

I am working on it.

I am using your code but I do not get it right as yet, I will continue and if I am still having problems I will let you know.

Thanks again.


Hi Andrew,

Here’s a function that takes a FolderItem, an Index, and the size in pixels requested and returns a Picture (or Nil on error):

What does the Index refer to? For example the folder item is Desktop, what is index?


OK Andrew,
Your code is for regular folder items and I understand that, it works great.

Could you give me an example for a folder, e.g. any folder on the Desktop using IconsExtract

I see that there is the example – iconsext.exe /save “c:\winnt\system32\shell32.dll” “c:\icons” -icons -cursors
in their example but I do not quite understand how to implement that for a folder, any folder, on the desktop, or a system folder like “Desktop” or MyComputer/This PC.



There is not an “exact” icon for the special folders you mention. What you will find in windows is a variety of ways to assign any icon you please to the object (folder, file, executable, Etc.)
There are a number of windows icons stored on dlls and executables, that you can use at your liking, as Andrew pointed out. However, it is recommended that you analyze one of the windows files that contains common icons (like rundll32.exe) with a resource analyzer.
When you decide which icon to use for your purpose, you have to programmatically extract it at runtime. You will have to know the index of the icon you want to use. The index is like the serial number that indicates the position of the resource icon inside the file you want to extract it from.
Alternatively you can use standalone icons and assign them instead of the stock ones. This allows you to create the icons yourself with an icon editor.

OK, I understand now, Thanks.