我正在使用以下代码动态链接到LoadIconWithScaleDown API,以便我的代码能够在Windows XP上运行:
HRESULT (WINAPI *pfnLoadIconWithScaleDown)(HINSTANCE, PCWSTR, int, int, HICON *);
HMODULE hComCtrl32 = LoadLibrary(_T("Comctl32.dll"));
if(hComCtrl32)
{
(FARPROC&)pfnLoadIconWithScaleDown = GetProcAddress(hComCtrl32, "LoadIconWithScaleDownW");
}
我在Windows 7上尝试此代码,但'pfnLoadIconWithScaleDown'始终为NULL。为什么呢?
答案 0 :(得分:3)
LoadIconWithScaleDown()
没有ASCII(A
)和UNICODE(W
)版本,因此请将GetProcAddress()
调用更改为:
pfnLoadIconWithScaleDown = GetProcAddress(hComCtrl32, "LoadIconWithScaleDown");