James Hawkins : advpack: Implement LaunchINFSectionEx.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Apr 11 05:05:09 CDT 2006


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

Author: James Hawkins <truiken at gmail.com>
Date:   Tue Apr 11 00:17:36 2006 -0500

advpack: Implement LaunchINFSectionEx.

---

 dlls/advpack/files.c   |   21 +------------
 dlls/advpack/install.c |   78 ++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/dlls/advpack/files.c b/dlls/advpack/files.c
index 5c7e636..90ba6cd 100644
--- a/dlls/advpack/files.c
+++ b/dlls/advpack/files.c
@@ -34,6 +34,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
 
+LPWSTR get_parameter(LPWSTR *params, WCHAR separator);
+
 /* converts an ansi double null-terminated list to a unicode list */
 static LPWSTR ansi_to_unicode_list(LPCSTR ansi_list)
 {
@@ -452,25 +454,6 @@ HRESULT WINAPI DelNodeW(LPCWSTR pszFileO
     return ret;
 }
 
-/* sequentially returns pointers to parameters in a parameter list
- * returns NULL if the parameter is empty, e.g. one,,three  */
-static LPWSTR get_parameter(LPWSTR *params, WCHAR separator)
-{
-    LPWSTR token = *params;
-
-    if (!*params)
-        return NULL;
-
-    *params = strchrW(*params, separator);
-    if (*params)
-        *(*params)++ = '\0';
-
-    if (!*token)
-        return NULL;
-
-    return token;
-}
-
 /***********************************************************************
  *             DelNodeRunDLL32A   (ADVPACK.@)
  *
diff --git a/dlls/advpack/install.c b/dlls/advpack/install.c
index 331e956..1cc7d32 100644
--- a/dlls/advpack/install.c
+++ b/dlls/advpack/install.c
@@ -31,6 +31,7 @@
 #include "setupapi.h"
 #include "advpub.h"
 #include "wine/debug.h"
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
 
@@ -41,6 +42,38 @@ WINE_DEFAULT_DEBUG_CHANNEL(advpack);
 
 #define ADV_HRESULT(x)  ((x & SPAPI_ERROR) ? HRESULT_FROM_SPAPI(x) : HRESULT_FROM_WIN32(x))
 
+/* sequentially returns pointers to parameters in a parameter list
+ * returns NULL if the parameter is empty, e.g. one,,three  */
+LPWSTR get_parameter(LPWSTR *params, WCHAR separator)
+{
+    LPWSTR token = *params;
+
+    if (!*params)
+        return NULL;
+
+    *params = strchrW(*params, separator);
+    if (*params)
+        *(*params)++ = '\0';
+
+    if (!*token)
+        return NULL;
+
+    return token;
+}
+
+static BOOL is_full_path(LPWSTR path)
+{
+    const int MIN_PATH_LEN = 3;
+
+    if (!path || lstrlenW(path) < MIN_PATH_LEN)
+        return FALSE;
+
+    if (path[1] == ':' || (path[0] == '\\' && path[1] == '\\'))
+        return TRUE;
+
+    return FALSE;
+}
+
 /* this structure very closely resembles parameters of RunSetupCommand() */
 typedef struct
 {
@@ -253,14 +286,51 @@ HRESULT WINAPI LaunchINFSectionExA(HWND 
  *    'A' Always reboot.
  *    'I' Reboot if needed (default).
  *    'N' No reboot.
- *  
+ *
  * BUGS
- *  Unimplemented.
+ *  Doesn't handle the reboot flag.
  */
 HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
 {
-    FIXME("(%p, %p, %s, %i): stub\n", hWnd, hInst, debugstr_w(cmdline), show);
-    return E_FAIL;
+    LPWSTR cmdline_copy, cmdline_ptr;
+    LPWSTR flags, ptr;
+    CABINFOW cabinfo;
+    HRESULT hr = S_OK;
+
+    TRACE("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_w(cmdline), show);
+
+    if (!cmdline)
+        return E_INVALIDARG;
+
+    cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
+    cmdline_ptr = cmdline_copy;
+    lstrcpyW(cmdline_copy, cmdline);
+
+    cabinfo.pszInf = get_parameter(&cmdline_ptr, ',');
+    cabinfo.pszSection = get_parameter(&cmdline_ptr, ',');
+    cabinfo.pszCab = get_parameter(&cmdline_ptr, ',');
+
+    flags = get_parameter(&cmdline_ptr, ',');
+    if (flags)
+        cabinfo.dwFlags = atolW(flags);
+
+    /* get the source path from the cab filename */
+    if (cabinfo.pszCab && *cabinfo.pszCab)
+    {
+        if (!is_full_path(cabinfo.pszCab))
+            goto done;
+
+        lstrcpyW(cabinfo.szSrcPath, cabinfo.pszCab);
+        ptr = strrchrW(cabinfo.szSrcPath, '\\');
+        *(++ptr) = '\0';
+    }
+
+    hr = ExecuteCabW(hWnd, &cabinfo, NULL);
+
+done:
+    HeapFree(GetProcessHeap(), 0, cmdline_copy);
+
+    return hr;
 }
 
 static HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE)




More information about the wine-cvs mailing list