可视化 使用 C++ API 注册 COM DLL 的所有接口
visual Register all interfaces of COM DLL using C++ API
我知道,我们可以使用 regsvr32 注册 COM DLL 的接口.exe
是任何可用的窗口C++ API,哪个 API 将注册 COM DLL 的接口。
谢谢!维贾伊·昆巴尼
regsvr32
所做的只是加载一个dll并调用DLL公开的DllRegisterServer函数。
如果你想编写自己的代码来做到这一点,那么你需要使用 LoadLibrary 和 GetProcAddress 来获取指向函数的指针,然后调用它。
你知道CLSID和COM dll文件路径吗?如果是,您可以使用API RegCreateKeyEx/SetKeyValue/RegCreateKeyEx/...将它们写入注册表,下面是一个示例:
[HKEY_CLASSES_ROOTCLSID{CLSID}InprocServer32]
@="C:\Windows\System32\oleaut32.dll"
"ThreadingModel"="Both"
LONG lreturn = RegCreateKeyEx(
HKEY_CLASSES_ROOT,
_T("CLSID${COMCLSID}"), // subkey
0, // reserved
NULL, // class string (can be NULL)
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL, // security attributes
&hKey,
NULL // receives the "disposition" (is it a new or existing key)
);
hr = __HRESULT_FROM_WIN32(lreturn);
// The default key value is a description of the object.
if (SUCCEEDED(hr))
{
hr = SetKeyValue(hKey, NULL, _T("your description"));
}
// Create the "InprocServer32" subkey
if (SUCCEEDED(hr))
{
const TCHAR *sServer = TEXT("InprocServer32");
LONG lreturn = RegCreateKeyEx(hKey, sServer, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubkey, NULL);
hr = __HRESULT_FROM_WIN32(lreturn);
}
if (SUCCEEDED(hr))
{
hr = SetKeyValue(hSubkey, NULL, _T("${COM DLL file Path}"));
}
// Add a new value to the subkey, for "ThreadingModel" = <threading model>
if (SUCCEEDED(hr))
{
hr = SetKeyValue(hSubkey, TEXT("ThreadingModel"), sThreadingModel);
}
相关文章:
- C++ 多个 DLL 之间的共享接口
- 可视化 使用 C++ API 注册 COM DLL 的所有接口
- 如何从MFC DLL中获取与COM包裹的C#对象的接口
- 使用抽象接口C++ dll 边界 -标头中的智能指针>?叫删除?
- 当从一个应用程序调用时,在DLL方法中创建COM接口指针是有效的,但当从另一个应用软件调用时则无效
- 如何在C#中使用C++DLL导出的接口指针
- Visual C++ 中 DLL 的 DLL 导出和接口
- 在主应用程序中声明的 dll 中实现接口 - C++
- 使用 ATL 编译 dll,并将方法参数作为接口,但将它们作为 coclass 获取
- 运算符=不是DLL中导出的C++__接口的成员
- exe和dll与不同C/C++运行库之间的接口
- 如何在DLL库的公共接口中使用pImpl习语
- 通过围绕C++接口创建C包装器,在FORTRAN中调用C++dll文件
- 我的Java GUI与我的超酷专有dll接口.如何防止第三方与此 dll 接口
- 使用接口从 dll 导出类
- 从 DLL (C++) 获取虚拟类接口
- 从可锁定容器的DLL接口隐藏Boost::互斥
- C#对导出抽象类/接口的C++DLL函数的消耗
- std::字符串流类需要有dll接口
- 如何在VC++2015全程序优化的情况下正确地从dll中公开接口