您的位置:首页 > 编程语言 > Qt开发

QT 插件调用

2015-01-22 15:53 190 查看
#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;
}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: