我正在开发一个需要使用 lib 魔术库来检测文件 mime 类型的项目,我正在使用 64 位版本的 windows(参见:https ://github.com/nscaife/file-windows )我的项目本身是我将从 python 调用它的 C dll。加载库工作正常,但是当我使用 GetProcAddress() 访问某些函数时,它返回 NULL 并且 GetLastError() 函数返回 126。请参阅我的代码:
int DLL_EXPORT mag()
{
char *actual_file = "test.db";
const char *magic_full;
HMODULE hModule = LoadLibrary("libmagic-1.dll");
if(hModule == NULL) //No problem here
return GetLastError();
magic_t (*t0)(int) = (void *) GetProcAddress(hModule, "magic_open");
const char (*t)(magic_t, const char *) = (void *)
GetProcAddress(hModule, "magic_file");
if(t0 == NULL && t == NULL);
return GetLastError();
magic_t magic_cookie;
magic_cookie = t0(MAGIC_MIME);
magic_full = t(magic_cookie, actual_file);
return 0;
}
这里有什么问题?