我在XE7中有一个dll-ready接口,我想在Visual Studio 2013中使用它。 在32位工作正常,但在64位我试图调用接口类的任何方法时遇到异常。
Embarcadero XE7项目是这样的:
class Interface
{
public:
virtual ~Interface() { }
virtual void Member1() = 0;
};
class Impl : public Interface
{
public:
virtual void Member1() { }
};
Impl* Impl::GetInstance()
{
static Impl instance;
return &instance;
}
extern "C" Interface* _stdcall _export GetImplementation()
{
return (Interface*)Impl::GetInstance();
}
在Visual Studio中,我执行以下操作:
typedef Interface* (_stdcall GetImpl) ();
HMODULE hHandle = LoadLibrary(...);
GetImpl *fGetImpl = NULL;
fGetImpl = (GetImpl*)GetProcAddress(hHandle, "GetImplementation");
if (fGetImpl)
{
Interface *pInterfase = fGetImpl();
if (pInterfase)
{
pInterfase->Member1();
}
}
我不知道为什么在64位崩溃。
提前致谢。
Ignasi