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
。