vs2015中的loadtypelib错误 [英] Loadtypelib error in vs2015

查看:184
本文介绍了vs2015中的loadtypelib错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将我们的项目从vs2005转换为vs2015.我们能够清除构建错误,但是现在我们在LoadTypeLib函数调用中遇到运行时错误

错误是加载类型库/DLL时出错"

下面是代码

We are converting our projects from vs2005 to vs2015. We able to clear the build error but now we are getting runtime error at LoadTypeLib function call

Error is "Error loading type library/DLL"

Below is the code

HRESULT LoadTypeInfoFromThisModule(REFIID riid, ITypeInfo **ppti) 
{
	*ppti = 0;
    char szFileName[MAX_PATH];

    GetModuleFileNameA((HMODULE)moduleHandle, szFileName, MAX_PATH);

    OLECHAR wszFileName[MAX_PATH];

    mbstowcs(wszFileName, szFileName, MAX_PATH);

    ITypeLib *ptl = 0;

    HRESULT hr = LoadTypeLib(wszFileName, &ptl);

    if (SUCCEEDED(hr)) 
	{
        hr = ptl->GetTypeInfoOfGuid(riid, ppti);
        ptl->Release();
    }

    return hr;
}


我可以知道为什么会引发此错误.相同的代码在vs2005中可以正常工作

我尝试过的事情:

如果我在VS2015项目中使用vs2005 dll,则它能够加载


May I know why this error will be thrown. The same code is working fine in vs2005

What I have tried:

If i use the vs2005 dll with in VS2015 project then it able to load

推荐答案

这些错误消息很奇怪,但确实如此.可能是该dll位于不同的目录中,或者某些字符串从ASCII更改为UNICODE.
These error messages are weired but true. It can be that the dll is in a different directory or some string changes from ASCII to UNICODE.


这篇关于vs2015中的loadtypelib错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆