merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / xmerge / source / regutil / regutil.cpp
blob17b1656fb282de1318cd98ef166f013be3801f1d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * Simple Application which calls the DllRegisterServer or DllUnregisterServer functions
4 * of the XMerge ActiveSync plugin.
5 */
8 #include <stdio.h>
9 #include <string.h>
10 #include <windows.h>
13 typedef HRESULT (STDAPICALLTYPE *DLLREGISTERSERVER)(void);
14 typedef HRESULT (STDAPICALLTYPE *DLLUNREGISTERSERVER)(void);
16 int main(int argc, char* argv[])
18 BOOL bUninstall = FALSE;
19 int nPathIndex = 1;
21 if (argc < 2 || argc > 3)
23 printf("\nUsage: regutil [/u] <Full Path of XMergeSync.dll>\n\n");
24 return -1;
28 if (argc == 3)
30 if (strcmp("/u", argv[1]))
32 printf("\nUnrecognised option: %s\n", argv[1]);
33 return -1;
36 bUninstall = TRUE;
37 nPathIndex = 2;
41 // Dynamically load the library
42 HMODULE hmXMDll = LoadLibrary(argv[nPathIndex]);
44 if (hmXMDll == NULL)
46 printf("\nUnable to load the library %s\n", argv[nPathIndex]);
47 return -1;
51 // Get an offset to the either the DllRegisterServer or DllUnregisterServer functions
52 if (!bUninstall)
54 printf("\nRegistering %s ... ", argv[nPathIndex]);
56 DLLREGISTERSERVER DllRegisterServer = (DLLREGISTERSERVER)GetProcAddress(hmXMDll, "DllRegisterServer");
58 if (DllRegisterServer == NULL)
60 printf("failed.\n\nDllRegisterServer is not present in library.\n");
61 return -1;
64 // Now call the procedure ...
65 HRESULT regResult = DllRegisterServer() ;
67 if (regResult != S_OK)
69 printf("failed.\n");
70 return -1;
73 else
75 printf("\nUnregistering %s ... ", argv[nPathIndex]);
77 DLLUNREGISTERSERVER DllUnregisterServer = (DLLUNREGISTERSERVER)GetProcAddress(hmXMDll, "DllUnregisterServer");
79 if (DllUnregisterServer == NULL)
81 printf("failed.\n\nDllUnregisterServer is not present in library.\n");
82 return -1;
85 // Now call the procedure ...
86 HRESULT regResult = DllUnregisterServer() ;
88 if (regResult != S_OK)
90 printf("failed.\n");
91 return -1;
96 printf("done.\n");
99 // Clean up
100 FreeLibrary(hmXMDll);
102 return 0;
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */