I know, we can register interfaces of COM DLL using regsvr32.exe
is any windows C++ API available, Which API will register interfaces of COM DLL.
Thanks! Vijay Kumbhani
I know, we can register interfaces of COM DLL using regsvr32.exe
is any windows C++ API available, Which API will register interfaces of COM DLL.
Thanks! Vijay Kumbhani
All regsvr32 does is load a dll and call the DllRegisterServer function exposed by the DLL.
If you want to write your own code to do this then you need to use LoadLibrary and GetProcAddress to get a pointer to the function, and then just call it.
Do you know the CLSID and COM dll file path? If yes, you can write them into registry with API RegCreateKeyEx/SetKeyValue/RegCreateKeyEx/..., here is a example:
[HKEY_CLASSES_ROOT\CLSID\{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);
}