diff ui/installwrapper.cpp @ 1159:0ddb173bcd8b

(issue36) Use 8 bit encoding for cinst process start
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 18 Sep 2014 15:46:49 +0200
parents a7a72353d6d2
children 2a1206932f53
line wrap: on
line diff
--- a/ui/installwrapper.cpp	Thu Sep 18 15:43:48 2014 +0200
+++ b/ui/installwrapper.cpp	Thu Sep 18 15:46:49 2014 +0200
@@ -97,9 +97,9 @@
      * and not a pipe for communication. In debug mode the installer
      * also makes use of output debug string. */
     DWORD retval = 0;
-    SHELLEXECUTEINFOW shExecInfo;
+    SHELLEXECUTEINFOA shExecInfo;
 
-    memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOW));
+    memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOA));
 
     /* Windows needs each parameter packed in " */
     QString parameters = "\"list=" + mCertListFile +
@@ -109,29 +109,36 @@
         parameters += " --debug";
     }
 
-    shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
+    shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
     shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
     if (!is_system_install()) {
-        shExecInfo.lpVerb = L"open";
+        shExecInfo.lpVerb = "open";
     } else {
-        shExecInfo.lpVerb = L"runas";
+        shExecInfo.lpVerb = "runas";
     }
-    shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (cinstFileName.utf16());
-    shExecInfo.lpParameters =  reinterpret_cast<LPCWSTR> (parameters.utf16());
+    shExecInfo.lpFile = strdup(cinstFileName.toLocal8Bit().constData());
+    shExecInfo.lpParameters = strdup(parameters.toUtf8().constData());
 
     qDebug() << "Starting process " << cinstFileName <<" params: " << parameters;
 
-    if (!ShellExecuteExW(&shExecInfo)) {
+    if (!ShellExecuteExA(&shExecInfo)) {
         char* errmsg = getLastErrorMsg();
         QString qerrmsg = QString::fromUtf8(errmsg);
         free(errmsg);
         emit error(tr("Error executing process: %1").arg(qerrmsg));
         fclose(vres.fptr);
+        free((void*)shExecInfo.lpFile);
+        free((void*)shExecInfo.lpParameters);
         return;
     }
 
     retval = WaitForSingleObject(shExecInfo.hProcess, INSTALL_TIMEOUT);
 
+    free((void*)shExecInfo.lpFile);
+    free((void*)shExecInfo.lpParameters);
+    shExecInfo.lpFile = NULL;
+    shExecInfo.lpParameters = NULL;
+
     if (retval != WAIT_OBJECT_0) {
         if (retval == WAIT_FAILED) {
             char* errmsg = getLastErrorMsg();

http://wald.intevation.org/projects/trustbridge/