0

我有一个在 XE7 中完成的 dll 就绪接口,我想在 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 位中崩溃。

提前致谢。

伊格纳西

4

0 回答 0