【代码】
void CShellFuncDlg::OnButton1()
{
// TODO: Add your control notification handler code here
int (WINAPI *PickIconDlg)(HWND, PWSTR, UINT, int *);
HMODULE hmdl = LoadLibrary(TEXT("shell32.dll"));
PickIconDlg = (int (WINAPI *)(HWND, PWSTR, UINT, int *))GetProcAddress(hmdl, "PickIconDlg");
WCHAR path[MAX_PATH] = L"C:\\windows\\system32\\shell32.dll";
int index = 10;
int result = PickIconDlg(NULL, path, MAX_PATH, &index);
WCHAR str[MAX_PATH + 50];
swprintf(str, L"You have chosen Icon %d in %s", index, path);
MessageBoxW(m_hWnd, str, L"Icon", MB_ICONINFORMATION);
FreeLibrary(hmdl);
}
【运行效果】