HRESULT __stdcall DllRegisterServer()
{
char DllPath[MAX_PATH];
GetModuleFileName(g_hInstance, DllPath, sizeof(DllPath));
// Convert DllPath to wide characters
OLECHAR wDllPath[MAX_PATH];
mbstowcs(wDllPath, DllPath, sizeof(wDllPath));
ITypeLib* pTypeLib;
HRESULT hr =
LoadTypeLibEx(wDllPath, REGKIND_REGISTER, &pTypeLib);
if(FAILED(hr))
return hr;
pTypeLib->Release();
return RegisterServerEx(g_regData, DllPath);
}
HRESULT __stdcall DllUnregisterServer()
{
UnRegisterTypeLib(LIBID_Component, 1, 0,
LANG_NEUTRAL, SYS_WIN32);
return UnregisterServerEx(g_regData);
}