QT 插件调用

来源:互联网 发布:标准型矩阵是什么 编辑:程序博客网 时间:2024/06/08 06:15
#ifndef DMREGISTER
#define DMREGISTER
#include <Windows.h>
#include <QLibrary>
#include "atlbase.h"
//#include "dm.tlh"
struct Idmsoft;
Idmsoft* DmReg(const char* file);
#endif // DMREGISTER
#include "DmReg.h"
#include "dm.tlh"
//#include "atlcom.h"
//#import "D:\\3.1233\\dm.dll" no_namespace
typedef   HRESULT (__stdcall *Func) (REFCLSID,REFIID,LPVOID*);
Idmsoft *DmReg(const char* file)
{
    //CoInitialize(0);
    HRESULT  hr;
    Func GetClass=nullptr;
    GetClass=(Func)QLibrary::resolve(file,"DllGetClassObject");
    if(!GetClass)return nullptr;
    IClassFactory* pFactory=nullptr;
    hr=GetClass(__uuidof(dmsoft),IID_IClassFactory,(LPVOID*)&pFactory);
    if(FAILED(hr))return nullptr;
    Idmsoft* idmsoft=nullptr;
    hr=pFactory->CreateInstance(NULL,__uuidof(Idmsoft),(LPVOID*)&idmsoft);
    pFactory->Release();
    if(!idmsoft)return nullptr;
    return idmsoft;
}

                                             
0 0