Roy Shea : mstask: Implemented DllRegisterServer.

Alexandre Julliard julliard at winehq.org
Tue Jul 29 07:16:39 CDT 2008


Module: wine
Branch: master
Commit: 6e5bfbfe17d71605973f16ed25d30934948ea1b6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6e5bfbfe17d71605973f16ed25d30934948ea1b6

Author: Roy Shea <royshea at gmail.com>
Date:   Mon Jul 28 12:06:24 2008 -0700

mstask: Implemented DllRegisterServer.

---

 dlls/mstask/Makefile.in   |    2 +
 dlls/mstask/mstask.inf    |   16 +++++++
 dlls/mstask/mstask.spec   |    1 +
 dlls/mstask/mstask_main.c |   98 +++++++++++++++++++++++++++++++++++++++++++++
 dlls/mstask/rsrc.rc       |   20 +++++++++
 tools/wine.inf.in         |    1 +
 6 files changed, 138 insertions(+), 0 deletions(-)

diff --git a/dlls/mstask/Makefile.in b/dlls/mstask/Makefile.in
index 2202e22..ae6a99f 100644
--- a/dlls/mstask/Makefile.in
+++ b/dlls/mstask/Makefile.in
@@ -10,6 +10,8 @@ C_SRCS = \
 	mstask_main.c \
 	task_scheduler.c
 
+RC_SRCS = rsrc.rc
+
 IDL_I_SRCS = mstask_local.idl
 
 @MAKE_DLL_RULES@
diff --git a/dlls/mstask/mstask.inf b/dlls/mstask/mstask.inf
new file mode 100644
index 0000000..1056093
--- /dev/null
+++ b/dlls/mstask/mstask.inf
@@ -0,0 +1,16 @@
+[version]
+Signature="$CHICAGO$"
+
+[RegisterDll]
+AddReg=Classes.Reg
+
+[UnregisterDll]
+DelReg=Classes.Reg
+
+[Classes.Reg]
+HKCR,"CLSID\%CLSID_CTaskScheduler%",,,"CTaskScheduler"
+HKCR,"CLSID\%CLSID_CTaskScheduler%\InProcServer32",,,"mstask.dll"
+HKCR,"CLSID\%CLSID_CTaskScheduler%\InProcServer32","ThreadingModel",,"Both"
+HKCR,"CLSID\%CLSID_CTask%",,,"CTask"
+HKCR,"CLSID\%CLSID_CTask%\InProcServer32",,,"mstask.dll"
+HKCR,"CLSID\%CLSID_CTask%\InProcServer32","ThreadingModel",,"Both"
diff --git a/dlls/mstask/mstask.spec b/dlls/mstask/mstask.spec
index 24d5af5..5c4f208 100644
--- a/dlls/mstask/mstask.spec
+++ b/dlls/mstask/mstask.spec
@@ -24,3 +24,4 @@
 @ stub _SASetAccountInformation at 20
 @ stub _SASetNSAccountInformation at 12
 @ stub _SetNetScheduleAccountInformation at 12
+@ stdcall -private DllRegisterServer()
diff --git a/dlls/mstask/mstask_main.c b/dlls/mstask/mstask_main.c
index 61e0a99..53c3449 100644
--- a/dlls/mstask/mstask_main.c
+++ b/dlls/mstask/mstask_main.c
@@ -16,11 +16,18 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <stdio.h>
+
 #include "mstask_private.h"
+#include "winreg.h"
+#include "advpub.h"
+
 #include "wine/debug.h"
 
+
 WINE_DEFAULT_DEBUG_CHANNEL(mstask);
 
+static HINSTANCE hInst;
 LONG dll_ref = 0;
 
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
@@ -33,6 +40,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
             return FALSE;
         case DLL_PROCESS_ATTACH:
             DisableThreadLibraryCalls(hinstDLL);
+            hInst = hinstDLL;
             break;
         case DLL_PROCESS_DETACH:
             break;
@@ -57,3 +65,93 @@ HRESULT WINAPI DllCanUnloadNow(void)
 {
     return dll_ref != 0 ? S_FALSE : S_OK;
 }
+
+static inline char *mstask_strdup(const char *s)
+{
+    size_t n = strlen(s) + 1;
+    char *d = HeapAlloc(GetProcessHeap(), 0, n);
+    return d ? memcpy(d, s, n) : NULL;
+}
+
+static HRESULT init_register_strtable(STRTABLEA *strtable)
+{
+#define CLSID_EXPANSION_ENTRY(id) { "CLSID_" #id, &CLSID_ ## id }
+    static const struct
+    {
+        const char *name;
+        const CLSID *clsid;
+    }
+    expns[] =
+    {
+        CLSID_EXPANSION_ENTRY(CTaskScheduler),
+        CLSID_EXPANSION_ENTRY(CTask)
+    };
+#undef CLSID_EXPANSION_ENTRY
+    static STRENTRYA pse[sizeof expns / sizeof expns[0]];
+    int i;
+
+    strtable->cEntries = sizeof pse / sizeof pse[0];
+    strtable->pse = pse;
+    for (i = 0; i < strtable->cEntries; i++)
+    {
+        static const char dummy_sample[] =
+                "{12345678-1234-1234-1234-123456789012}";
+        const CLSID *clsid = expns[i].clsid;
+        pse[i].pszName = mstask_strdup(expns[i].name);
+        pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, sizeof dummy_sample);
+        if (!pse[i].pszName || !pse[i].pszValue)
+            return E_OUTOFMEMORY;
+        sprintf(pse[i].pszValue,
+                "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+                clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
+                clsid->Data4[1], clsid->Data4[2], clsid->Data4[3],
+                clsid->Data4[4], clsid->Data4[5], clsid->Data4[6],
+                clsid->Data4[7]);
+    }
+
+    return S_OK;
+}
+
+static void cleanup_register_strtable(STRTABLEA *strtable)
+{
+    int i;
+    for (i = 0; i < strtable->cEntries; i++)
+    {
+        HeapFree(GetProcessHeap(), 0, strtable->pse[i].pszName);
+        HeapFree(GetProcessHeap(), 0, strtable->pse[i].pszValue);
+        if (!strtable->pse[i].pszName || !strtable->pse[i].pszValue)
+            return;
+    }
+}
+
+static HRESULT register_mstask(BOOL do_register)
+{
+    HRESULT hr;
+    STRTABLEA strtable;
+    HMODULE hAdvpack;
+    HRESULT (WINAPI *pRegInstall)(HMODULE hm,
+            LPCSTR pszSection, const STRTABLEA* pstTable);
+    static const WCHAR wszAdvpack[] =
+            {'a','d','v','p','a','c','k','.','d','l','l',0};
+
+    TRACE("(%x)\n", do_register);
+
+    hAdvpack = LoadLibraryW(wszAdvpack);
+    pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
+
+    hr = init_register_strtable(&strtable);
+    if (SUCCEEDED(hr))
+        hr = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll",
+                &strtable);
+    cleanup_register_strtable(&strtable);
+
+    if (FAILED(hr))
+        WINE_ERR("RegInstall failed: %08x\n", hr);
+
+    return hr;
+}
+
+HRESULT WINAPI DllRegisterServer(void)
+{
+    return register_mstask(TRUE);
+}
diff --git a/dlls/mstask/rsrc.rc b/dlls/mstask/rsrc.rc
new file mode 100644
index 0000000..9915e02
--- /dev/null
+++ b/dlls/mstask/rsrc.rc
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2008 Google (Roy Shea)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/* @makedep: mstask.inf */
+REGINST REGINST mstask.inf
diff --git a/tools/wine.inf.in b/tools/wine.inf.in
index e8e4df6..0d116df 100644
--- a/tools/wine.inf.in
+++ b/tools/wine.inf.in
@@ -2213,6 +2213,7 @@ HKLM,%CurrentVersion%\Telephony\Country List\998,"SameAreaRule",,"G"
 11,,msi.dll,1
 11,,msiexec.exe,1
 11,,msimtf.dll,1
+11,,mstask.dll,1
 11,,msxml3.dll,1
 11,,objsel.dll,1
 11,,qcap.dll,1




More information about the wine-cvs mailing list