aboutsummaryrefslogtreecommitdiff
path: root/qga/vss-win32/install.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qga/vss-win32/install.cpp')
-rw-r--r--qga/vss-win32/install.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index 8494413..7b25d90 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -39,7 +39,7 @@ const GUID CLSID_WbemLocator = { 0x4590f811, 0x1d3a, 0x11d0,
const GUID IID_IWbemLocator = { 0xdc12a687, 0x737f, 0x11cf,
{0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24} };
-void errmsg(DWORD err, const char *text)
+static void errmsg(DWORD err, const char *text)
{
/*
* `text' contains function call statement when errmsg is called via chk().
@@ -242,6 +242,7 @@ out:
}
/* Unregister this module from COM+ Applications Catalog */
+STDAPI COMUnregister(void);
STDAPI COMUnregister(void)
{
qga_debug_begin;
@@ -256,6 +257,7 @@ out:
}
/* Register this module to COM+ Applications Catalog */
+STDAPI COMRegister(void);
STDAPI COMRegister(void)
{
qga_debug_begin;
@@ -285,9 +287,13 @@ STDAPI COMRegister(void)
chk(QGAProviderFind(QGAProviderCount, (void *)&count));
if (count) {
- errmsg(E_ABORT, "QGA VSS Provider is already installed");
- qga_debug_end;
- return E_ABORT;
+ qga_debug("QGA VSS Provider is already installed. Attempting to unregister first.");
+ hr = COMUnregister();
+ if (FAILED(hr)) {
+ errmsg(hr, "Failed to unregister existing QGA VSS Provider. Aborting installation.");
+ qga_debug_end;
+ return E_ABORT;
+ }
}
chk(CoCreateInstance(CLSID_COMAdminCatalog, NULL, CLSCTX_INPROC_SERVER,
@@ -380,11 +386,16 @@ out:
return hr;
}
+STDAPI_(void) CALLBACK DLLCOMRegister(HWND, HINSTANCE, LPSTR, int);
STDAPI_(void) CALLBACK DLLCOMRegister(HWND, HINSTANCE, LPSTR, int)
{
- COMRegister();
+ HRESULT hr = COMRegister();
+ if (FAILED(hr)) {
+ exit(hr);
+ }
}
+STDAPI_(void) CALLBACK DLLCOMUnregister(HWND, HINSTANCE, LPSTR, int);
STDAPI_(void) CALLBACK DLLCOMUnregister(HWND, HINSTANCE, LPSTR, int)
{
COMUnregister();