Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
PickIconDlg (shell32)
Shows the common Pick-Icon-Dialog

C# Signature:

[DllImport("shell32.dll", CharSet=CharSet.Unicode)]
private static extern int PickIconDlg(IntPtr hwndOwner, System.Text.StringBuilder lpstrFile, int nMaxFile, ref int lpdwIconIndex);

VB Signature:

Declare Unicode Function PickIconDlg Lib "Shell32" Alias "PickIconDlg" (ByVal hwndOwner As IntPtr, ByVal lpstrFile As String, ByVal nMaxFile As Integer, ByRef lpdwIconIndex As Integer) As Integer


This function behaves differently on 9x/ME than on Windows NT->XP

Tips & Tricks:

Please add some!

Sample Code:

C# Version:

string iconfile;
int iconindex = 0;
int retval;
System.Text.StringBuilder sb;

iconfile = Environment.GetFolderPath(Environment.SpecialFolder.System);
iconfile = iconfile + @"\shell32.dll";
sb = new System.Text.StringBuilder(iconfile, 500);
retval = PickIconDlg(this.Handle, sb, sb.Length + 1, ref iconindex);
iconfile = sb.ToString();

Shouldn't it look like this:

retval = PickIconDlg(this.Handle, sb, sb.Capacity, ref iconindex);

VB.NET Version:

Dim iconfile As String = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\shell32.dll"

Dim iconindex As Integer ' Will store the index of the selected icon

Dim retval As Integer ' Will contain the result of the PickIconDlg. 1 = OK, 0 = Canceled

retval = PickIconDlg(Me.Handle, iconfile, iconfile.Length, iconindex)

MessageBox.Show("Result: " + retval.ToString() + vbCrLf + "Selected Icon Index: " + iconindex.ToString())

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version