Dim hShell As HINSTANCE
Dim SHChangeIconDialog As *Function(hWnd As HWND, ByRef lpszFilename As *Byte, Reserved As Long, ByRef lpIconIndex As Long) As Long
Dim str As *Byte, index As Long, flag As Long
Dim dwSize As Long, pwFileName As *Word
hShell = LoadLibrary("Shell32") As HINSTANCE
SHChangeIconDialog = GetProcAddress(hShell, 62 As *Byte) As *Function
flag=SHChangeIconDialog(hMainWnd, str, -1, index)
If flag=1 Then
MessageBox(hMainWnd, MakeStr(str), Str$(index), MB_OK)
End If
FreeLibrary(hShell As DWord)
Declare Function lstrlenW Lib "kernel32" (pwsz As *WCHAR) As Long
Function ChangeIconDialog(hwnd As HWND, ByRef Index As Long) As String
If VersionInfo.dwPlatformId <> VER_PLATFORM_WIN32_WINDOWS Then
Dim wstr[ELM(MAX_PATH)] As WCHAR
Dim SHChangeIconDialogW As PChangeIconDialogW
SHChangeIconDialogW = GetProcAddress(hShell, 62 As *Byte) As PChangeIconDialogW
If SHChangeIconDialogW(hwnd, wstr, MAX_PATH, Index) <> FALSE Then
ChangeIconDialog = ToMBString(wstr)
End If
Else
Dim str[ELM(MAX_PATH)] As Byte
Dim SHChangeIconDialogA As PChangeIconDialogA
SHChangeIconDialogA = GetProcAddress(hShell, 62 As *Byte) As PChangeIconDialogA
If SHChangeIconDialogA(hwnd, str, MAX_PATH, Index) <> FALSE Then
ChangeIconDialog = str
End If
End If
End Function
Function ToMBString(pwsz As *WCHAR) As String
Dim lenW As Long
lenW = lstrlenW(pwsz)
Dim lenA As Long
lenA = WideCharToMultiByte(CP_ACP, 0, pwsz, lenW, 0, 0, 0, 0)
ToMBString = ZeroString(lenA)
WideCharToMultiByte(CP_ACP, 0, pwsz, lenW, StrPtr(ToMBString), lenA, 0, 0)
End Function
Typedef PChangeIconDialogW = *Function(hWnd As HWND, lpszFilename As *Word, Reserved As Long, ByRef lpIconIndex As Long) As Long
Typedef PChangeIconDialogA = *Function(hWnd As HWND, lpszFilename As String, Reserved As Long, ByRef lpIconIndex As Long) As Long