Example #1
0
extern "C" BOOL RegisterComServers (char *modulePath)
{
	BOOL ret = TRUE;
	wchar_t mainModule[1024], formatModule[1024];
	CComPtr<ITypeLib> tl, tl2;

	wsprintfW (mainModule, L"%hsGostCrypt.exe", modulePath);
	wsprintfW (formatModule, L"%hsGostCrypt Format.exe", modulePath);

	UnRegisterTypeLib (LIBID_GostCryptMainCom, GST_MAIN_COM_VERSION_MAJOR, GST_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32);
	UnRegisterTypeLib (LIBID_GostCryptFormatCom, GST_FORMAT_COM_VERSION_MAJOR, GST_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32);

	wchar_t setupModule[MAX_PATH];
	GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0]));

	CRegObject ro;
	HRESULT r;

	if (!SUCCEEDED (r = ro.FinalConstruct ())
		|| !SUCCEEDED (r = ro.AddReplacement (L"MAIN_MODULE", mainModule))
		|| !SUCCEEDED (r = ro.AddReplacement (L"FORMAT_MODULE", formatModule))
		|| !SUCCEEDED (r = ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY"))
		|| !SUCCEEDED (r = LoadTypeLib (mainModule, &tl))
		|| !SUCCEEDED (r = RegisterTypeLib (tl, mainModule, 0))
		|| !SUCCEEDED (r = LoadTypeLib (formatModule, &tl2))
		|| !SUCCEEDED (r = RegisterTypeLib (tl2, formatModule, 0)))
	{
		MessageBox (MainDlg, _com_error (r).ErrorMessage(), GST_APP_NAME, MB_ICONERROR);
		ret = FALSE;
	}

	ro.FinalRelease ();
	return ret;
}
Example #2
0
extern "C" BOOL UnregisterComServers (char *modulePath)
{
	BOOL ret;

	if (UnRegisterTypeLib (LIBID_GostCryptMainCom, GST_MAIN_COM_VERSION_MAJOR, GST_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32) != S_OK)
		return FALSE;
	if (UnRegisterTypeLib (LIBID_GostCryptFormatCom, GST_FORMAT_COM_VERSION_MAJOR, GST_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32) != S_OK)
		return FALSE;

	wchar_t module[1024];
	CRegObject ro;
	ro.FinalConstruct ();

	wsprintfW (module, L"%hsGostCrypt.exe", modulePath);
	ro.AddReplacement (L"MAIN_MODULE", module);

	wsprintfW (module, L"%hsGostCrypt Format.exe", modulePath);
	ro.AddReplacement (L"FORMAT_MODULE", module);

	wchar_t setupModule[MAX_PATH];
	GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0]));

	ret = ro.ResourceUnregister (setupModule, IDR_COMREG, L"REGISTRY") == S_OK;

	ro.FinalRelease ();
	return ret;
}
Example #3
0
extern "C" BOOL RegisterComServers (char *modulePath)
{
	BOOL ret = FALSE;
	wchar_t mainModule[1024], formatModule[1024];
	CComPtr<ITypeLib> tl, tl2;

	wsprintfW (mainModule, L"%hsTrueCrypt.exe", modulePath);
	wsprintfW (formatModule, L"%hsTrueCrypt Format.exe", modulePath);

	UnRegisterTypeLib (LIBID_TrueCryptMainCom, 1, 0, 0, SYS_WIN32);
	UnRegisterTypeLib (LIBID_TrueCryptFormatCom, 1, 0, 0, SYS_WIN32);

	CRegObject ro;
	ro.FinalConstruct ();

	ro.AddReplacement (L"MAIN_MODULE", mainModule);
	ro.AddReplacement (L"FORMAT_MODULE", formatModule);

	wchar_t setupModule[MAX_PATH];
	GetModuleFileNameW (NULL, setupModule, sizeof (setupModule) / sizeof (setupModule[0]));
	if (ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY") != S_OK)
		goto error;

	if (LoadTypeLib (mainModule, &tl) != S_OK
		|| RegisterTypeLib (tl, mainModule, 0) != S_OK)
		goto error;

	if (LoadTypeLib (formatModule, &tl2) != S_OK
		|| RegisterTypeLib (tl2, formatModule, 0) != S_OK)
		goto error;

	ret = TRUE;
error:
	ro.FinalRelease ();
	return ret;
}