0
我想使用WindowsCodecs.dll
中的函数,但MinGW具有不完整且缺少WinAPI标头以及导入库。请看下面的演示:无法链接到WICConvertBitmapSource
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
// ---------- dummy declarations, because MinGW got no wincodec.h ----------
typedef REFGUID REFWICPixelFormatGUID;
typedef VOID IWICBitmapSource;
HRESULT WINAPI WICConvertBitmapSource(
REFWICPixelFormatGUID dstFormat,
IWICBitmapSource *pISrc,
IWICBitmapSource **ppIDst);
// -------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpLine, int nShow)
{
#ifdef LOAD_FROM_DLL
typedef HRESULT (WINAPI *PWICConvertBitmapSource)(
REFWICPixelFormatGUID, IWICBitmapSource *, IWICBitmapSource **);
HMODULE hDll = LoadLibrary("WindowsCodecs.dll");
PWICConvertBitmapSource pFunc =
(PWICConvertBitmapSource)GetProcAddress(hDll, "WICConvertBitmapSource");
printf("WICConvertBitmapSource: 0x%p.\n", pFunc);
pFunc(NULL, NULL, NULL);
FreeLibrary(hDll);
#else
WICConvertBitmapSource(NULL, NULL, NULL);
#endif
return 0;
}
当gcc test.c -DLOAD_FROM_DEF
建成,功能的程序打印地址和正确终止。虽然,当与导入库从以下DEF链接:
LIBRARY WindowsCodecs.dll
EXPORTS
[email protected]
,这个错误弹出:
The procedure entry point [email protected] could
not be located in the dynamic link library WindowsCodecs.dll.
令人惊讶的是,如果我从高清去除WICConvertBitmapSource
从源头和@12
声明文件,程序链接并运行正常。
如何创建正确的导入库?
备注:我在Windows 7 SP1上运行MinGW。我的gcc版本是4.7.0,安装了w32api 3.17。该问题出现在许多功能中,如GdiAlphaBlend
或SHCreateStreamOnFileEx
。