merge the formfield patch from ooo-build
[ooovba.git] / xmerge / source / regutil / regutil.cpp
blob188454df7568e2087f5dcde7591189066d6d46ae
1 /*
2 * Simple Application which calls the DllRegisterServer or DllUnregisterServer functions
3 * of the XMerge ActiveSync plugin.
4 */
7 #include <stdio.h>
8 #include <string.h>
9 #include <windows.h>
12 typedef HRESULT (STDAPICALLTYPE *DLLREGISTERSERVER)(void);
13 typedef HRESULT (STDAPICALLTYPE *DLLUNREGISTERSERVER)(void);
15 int main(int argc, char* argv[])
17 BOOL bUninstall = FALSE;
18 int nPathIndex = 1;
20 if (argc < 2 || argc > 3)
22 printf("\nUsage: regutil [/u] <Full Path of XMergeSync.dll>\n\n");
23 return -1;
27 if (argc == 3)
29 if (strcmp("/u", argv[1]))
31 printf("\nUnrecognised option: %s\n", argv[1]);
32 return -1;
35 bUninstall = TRUE;
36 nPathIndex = 2;
40 // Dynamically load the library
41 HMODULE hmXMDll = LoadLibrary(argv[nPathIndex]);
43 if (hmXMDll == NULL)
45 printf("\nUnable to load the library %s\n", argv[nPathIndex]);
46 return -1;
50 // Get an offset to the either the DllRegisterServer or DllUnregisterServer functions
51 if (!bUninstall)
53 printf("\nRegistering %s ... ", argv[nPathIndex]);
55 DLLREGISTERSERVER DllRegisterServer = (DLLREGISTERSERVER)GetProcAddress(hmXMDll, "DllRegisterServer");
57 if (DllRegisterServer == NULL)
59 printf("failed.\n\nDllRegisterServer is not present in library.\n");
60 return -1;
63 // Now call the procedure ...
64 HRESULT regResult = DllRegisterServer() ;
66 if (regResult != S_OK)
68 printf("failed.\n");
69 return -1;
72 else
74 printf("\nUnregistering %s ... ", argv[nPathIndex]);
76 DLLUNREGISTERSERVER DllUnregisterServer = (DLLUNREGISTERSERVER)GetProcAddress(hmXMDll, "DllUnregisterServer");
78 if (DllUnregisterServer == NULL)
80 printf("failed.\n\nDllUnregisterServer is not present in library.\n");
81 return -1;
84 // Now call the procedure ...
85 HRESULT regResult = DllUnregisterServer() ;
87 if (regResult != S_OK)
89 printf("failed.\n");
90 return -1;
95 printf("done.\n");
98 // Clean up
99 FreeLibrary(hmXMDll);
101 return 0;