- 注册时间
- 2021-4-16
- 最后登录
- 2024-3-7
- 在线时间
- 2 小时
编程入门
- 龙马币
- 36
|
C++免注册调用大漠插件
- #import "dm.dll" no_namespace
- #include "stdafx.h"
- //创建新的大漠对象
- Idmsoft * InitNewDm() {
- Idmsoft*m_dm = NULL;
- //COleVariant temp1,temp2;
- bool m_bInit = false;
- //下面直接加载dll创建对象,避免进行注册文件
- typedef HRESULT (__stdcall * pfnGCO) (REFCLSID, REFIID, void**);
- pfnGCO fnGCO = NULL;
- HINSTANCE hdllInst = LoadLibrary(L"dm.dll");
- fnGCO = (pfnGCO)GetProcAddress(hdllInst, "DllGetClassObject");
- if (fnGCO != 0) {
- IClassFactory* pcf = NULL;
- HRESULT hr=(fnGCO)(__uuidof(dmsoft), IID_IClassFactory, (void**)&pcf);
- if (SUCCEEDED(hr) && (pcf != NULL)) {
- hr = pcf->CreateInstance(NULL, __uuidof(Idmsoft), (void**)&m_dm);
- if ((SUCCEEDED(hr) && (m_dm != NULL))==FALSE)
- return false;
- }
- pcf->Release();
- m_bInit=true;
- } else
- m_bInit=false;
- return m_dm;
- }
复制代码
|
|