[DllImport("shell32.dll", CharSet=CharSet.Unicode)]
private static extern int PickIconDlg(IntPtr hwndOwner, System.Text.StringBuilder lpstrFile, int nMaxFile, ref int lpdwIconIndex);
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
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())