bits: Integrated service registration into qmgr (9/27)
Roy Shea
roy at cs.hmc.edu
Fri Nov 16 18:17:40 CST 2007
---
dlls/qmgr/Makefile.in | 4 +-
dlls/qmgr/qmgr.c | 8 +++-
dlls/qmgr/qmgr.spec | 4 +-
dlls/qmgr/qmgr_main.c | 98 +++++++++++++++++++++++++++++++++++++++++++++---
4 files changed, 103 insertions(+), 11 deletions(-)
diff --git a/dlls/qmgr/Makefile.in b/dlls/qmgr/Makefile.in
index aa3440d..5f18422 100644
--- a/dlls/qmgr/Makefile.in
+++ b/dlls/qmgr/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = qmgr.dll
-IMPORTS = kernel32
+IMPORTS = kernel32 advapi32 ole32 user32
EXTRALIBS =
C_SRCS = \
@@ -11,6 +11,8 @@ C_SRCS = \
qmgr_main.c \
qmgr.c
+RC_SRCS = rsrc.rc
+
IDL_I_SRCS = qmgr_local.idl
@MAKE_DLL_RULES@
diff --git a/dlls/qmgr/qmgr.c b/dlls/qmgr/qmgr.c
index 65106bc..3247dc0 100644
--- a/dlls/qmgr/qmgr.c
+++ b/dlls/qmgr/qmgr.c
@@ -93,7 +93,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyManager_GetErrorDescription(
}
-const IBackgroundCopyManagerVtbl BITS_IBackgroundCopyManager_Vtbl =
+static const IBackgroundCopyManagerVtbl BITS_IBackgroundCopyManager_Vtbl =
{
BITS_IBackgroundCopyManager_QueryInterface,
BITS_IBackgroundCopyManager_AddRef,
@@ -104,3 +104,9 @@ const IBackgroundCopyManagerVtbl BITS_IBackgroundCopyManager_Vtbl =
BITS_IBackgroundCopyManager_GetErrorDescription
};
+BackgroundCopyManagerImpl BITS_BackgroundCopyManager =
+{
+ &BITS_IBackgroundCopyManager_Vtbl,
+ 0
+};
+
diff --git a/dlls/qmgr/qmgr.spec b/dlls/qmgr/qmgr.spec
index c2eb3c0..37b010b 100644
--- a/dlls/qmgr/qmgr.spec
+++ b/dlls/qmgr/qmgr.spec
@@ -1,5 +1,5 @@
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
-@ stub DllRegisterServer
-@ stub DllUnregisterServer
+@ stdcall -private DllRegisterServer()
+@ stdcall -private DllUnregisterServer()
diff --git a/dlls/qmgr/qmgr_main.c b/dlls/qmgr/qmgr_main.c
index 89ba17c..a6fee51 100644
--- a/dlls/qmgr/qmgr_main.c
+++ b/dlls/qmgr/qmgr_main.c
@@ -21,45 +21,129 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <stdarg.h>
+#include <stdio.h>
-#include "windef.h"
-#include "winbase.h"
#include "objbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "advpub.h"
+#include "bits.h"
+#include "initguid.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
+/* Number of references to this DLL */
LONG dll_ref = 0;
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+/* Handle to the base address of this DLL */
+static HINSTANCE hInst;
+
+/* Other GUIDs used by this module */
+DEFINE_GUID(CLSID_BackgroundCopyQMgr, 0x69AD4AEE, 0x51BE, 0x439b, 0xA9,0x2C, 0x86,0xAE,0x49,0x0E,0x8B,0x30);
+
+/* Entry point for DLL */
+BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
- TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
+ TRACE("(%p, %d, %p)\n", hInstDLL, fdwReason, lpvReserved);
switch (fdwReason)
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hinstDLL);
+ DisableThreadLibraryCalls(hInstDLL);
+ hInst = hInstDLL;
break;
case DLL_PROCESS_DETACH:
break;
}
-
return TRUE;
}
+/* Retreive class object from DLL */
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
{
FIXME("Not implemented\n");
return E_NOTIMPL;
}
+/* Check to see if the DLL can be unloaded */
HRESULT WINAPI DllCanUnloadNow(void)
{
return dll_ref != 0 ? S_FALSE : S_OK;
}
+/* Helper macro used to package GUID strings to expand the INF string section */
+#define INF_SET_ID(id) \
+ do \
+ { \
+ static CHAR name[] = #id; \
+ \
+ pse[i].pszName = name; \
+ clsids[i++] = &id; \
+ } while (0)
+
+#define INF_SET_CLSID(clsid) INF_SET_ID(CLSID_ ## clsid)
+
+/* Use an INF file to register or unregister the DLL */
+static HRESULT register_server(BOOL do_register)
+{
+ HRESULT hres;
+ HMODULE hAdvpack;
+ typeof(RegInstallA) *pRegInstall;
+ STRTABLEA strtable;
+ STRENTRYA pse[2];
+ static CLSID const *clsids[2];
+ int i = 0;
+
+ static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
+
+ TRACE("(%x)\n", do_register);
+
+ INF_SET_CLSID(BackgroundCopyQMgr);
+ INF_SET_CLSID(BackgroundCopyManager);
+
+ strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
+ strtable.pse = pse;
+
+ for(i=0; i < strtable.cEntries; i++) {
+ pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
+ sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+ clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
+ clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
+ clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
+ }
+
+ hAdvpack = LoadLibraryW(wszAdvpack);
+ pRegInstall = (typeof(RegInstallA)*)GetProcAddress(hAdvpack, "RegInstall");
+
+ hres = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll", &strtable);
+
+ for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
+ HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
+
+ if(FAILED(hres)) {
+ ERR("RegInstall failed: %08x\n", hres);
+ }
+
+ return hres;
+}
+
+#undef INF_SET_CLSID
+#undef INF_SET_ID
+
+/* Register Queue Manager (BITS) server */
+HRESULT WINAPI DllRegisterServer(void)
+{
+ return register_server(TRUE);
+}
+
+/* Unregister Queue Manager (BITS) server */
+HRESULT WINAPI DllUnregisterServer(void)
+{
+ return register_server(FALSE);
+}
+
--
1.5.3.1
More information about the wine-patches
mailing list