James Hawkins : advpack: Use get_parameter to read the three parameters of RegisterOCX.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 17 05:55:21 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 1bc69125af049dbee432af45b2f2e5dff71ff986
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=1bc69125af049dbee432af45b2f2e5dff71ff986

Author: James Hawkins <truiken at gmail.com>
Date:   Mon Apr 17 01:50:46 2006 -0500

advpack: Use get_parameter to read the three parameters of RegisterOCX.

Use get_parameter to read the three parameters to RegisterOCX.
Remove the ERRs and TRACEs now that we return the HRESULT.

---

 dlls/advpack/advpack.c |   54 +++++++++++++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/dlls/advpack/advpack.c b/dlls/advpack/advpack.c
index 61ea5b7..4ee3b0c 100644
--- a/dlls/advpack/advpack.c
+++ b/dlls/advpack/advpack.c
@@ -416,44 +416,46 @@ HRESULT WINAPI RebootCheckOnInstallW(HWN
  */
 HRESULT WINAPI RegisterOCX(HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show)
 {
-    WCHAR wszBuff[MAX_PATH];
-    WCHAR* pwcComma;
-    HMODULE hm;
+    LPWSTR ocx_filename, str_flags, param;
+    LPWSTR cmdline_copy, cmdline_ptr;
+    UNICODE_STRING cmdlineW;
     DLLREGISTER pfnRegister;
-    HRESULT hr;
+    HRESULT hr = E_FAIL;
+    HMODULE hm = NULL;
+    DWORD size;
 
     TRACE("(%s)\n", debugstr_a(cmdline));
 
-    MultiByteToWideChar(CP_ACP, 0, cmdline, strlen(cmdline), wszBuff, MAX_PATH);
-    if ((pwcComma = strchrW( wszBuff, ',' ))) *pwcComma = 0;
+    RtlCreateUnicodeStringFromAsciiz(&cmdlineW, cmdline);
 
-    TRACE("Parsed DLL name (%s)\n", debugstr_w(wszBuff));
+    size = (lstrlenW(cmdlineW.Buffer) + 1) * sizeof(WCHAR);
+    cmdline_copy = HeapAlloc(GetProcessHeap(), 0, size);
+    cmdline_ptr = cmdline_copy;
+    lstrcpyW(cmdline_copy, cmdlineW.Buffer);
 
-    hm = LoadLibraryExW(wszBuff, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
+    ocx_filename = get_parameter(&cmdline_ptr, ',');
+    if (!ocx_filename || !*ocx_filename)
+        goto done;
+
+    str_flags = get_parameter(&cmdline_ptr, ',');
+    param = get_parameter(&cmdline_ptr, ',');
+
+    hm = LoadLibraryExW(ocx_filename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
     if (!hm)
-    {
-        ERR("Couldn't load DLL: %s\n", debugstr_w(wszBuff));
-        return E_FAIL;
-    }
+        goto done;
 
     pfnRegister = (DLLREGISTER)GetProcAddress(hm, "DllRegisterServer");
-    if (pfnRegister == NULL)
-    {
-        ERR("DllRegisterServer entry point not found\n");
-    }
-    else
-    {
-        hr = pfnRegister();
-        if (hr != S_OK)
-        {
-            ERR("DllRegisterServer entry point returned %08lx\n", hr);
-        }
-    }
+    if (!pfnRegister)
+        goto done;
 
-    TRACE("Successfully registered OCX\n");
+    hr = pfnRegister();
 
+done:
     FreeLibrary(hm);
-    return S_OK;
+    HeapFree(GetProcessHeap(), 0, cmdline_copy);
+    RtlFreeUnicodeString(&cmdlineW);
+
+    return hr;
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list