comparison 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
comparison
equal deleted inserted replaced
1158:ffdc8cba139a 1159:0ddb173bcd8b
95 * shell execute also means that we can not have stdout and stderr 95 * shell execute also means that we can not have stdout and stderr
96 * redirection. This is the reason we use command line parameters 96 * redirection. This is the reason we use command line parameters
97 * and not a pipe for communication. In debug mode the installer 97 * and not a pipe for communication. In debug mode the installer
98 * also makes use of output debug string. */ 98 * also makes use of output debug string. */
99 DWORD retval = 0; 99 DWORD retval = 0;
100 SHELLEXECUTEINFOW shExecInfo; 100 SHELLEXECUTEINFOA shExecInfo;
101 101
102 memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOW)); 102 memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOA));
103 103
104 /* Windows needs each parameter packed in " */ 104 /* Windows needs each parameter packed in " */
105 QString parameters = "\"list=" + mCertListFile + 105 QString parameters = "\"list=" + mCertListFile +
106 "\" \"choices=" + choicesFile.fileName() + "\""; 106 "\" \"choices=" + choicesFile.fileName() + "\"";
107 107
108 if (g_debug) { 108 if (g_debug) {
109 parameters += " --debug"; 109 parameters += " --debug";
110 } 110 }
111 111
112 shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW); 112 shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
113 shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 113 shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
114 if (!is_system_install()) { 114 if (!is_system_install()) {
115 shExecInfo.lpVerb = L"open"; 115 shExecInfo.lpVerb = "open";
116 } else { 116 } else {
117 shExecInfo.lpVerb = L"runas"; 117 shExecInfo.lpVerb = "runas";
118 } 118 }
119 shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (cinstFileName.utf16()); 119 shExecInfo.lpFile = strdup(cinstFileName.toLocal8Bit().constData());
120 shExecInfo.lpParameters = reinterpret_cast<LPCWSTR> (parameters.utf16()); 120 shExecInfo.lpParameters = strdup(parameters.toUtf8().constData());
121 121
122 qDebug() << "Starting process " << cinstFileName <<" params: " << parameters; 122 qDebug() << "Starting process " << cinstFileName <<" params: " << parameters;
123 123
124 if (!ShellExecuteExW(&shExecInfo)) { 124 if (!ShellExecuteExA(&shExecInfo)) {
125 char* errmsg = getLastErrorMsg(); 125 char* errmsg = getLastErrorMsg();
126 QString qerrmsg = QString::fromUtf8(errmsg); 126 QString qerrmsg = QString::fromUtf8(errmsg);
127 free(errmsg); 127 free(errmsg);
128 emit error(tr("Error executing process: %1").arg(qerrmsg)); 128 emit error(tr("Error executing process: %1").arg(qerrmsg));
129 fclose(vres.fptr); 129 fclose(vres.fptr);
130 free((void*)shExecInfo.lpFile);
131 free((void*)shExecInfo.lpParameters);
130 return; 132 return;
131 } 133 }
132 134
133 retval = WaitForSingleObject(shExecInfo.hProcess, INSTALL_TIMEOUT); 135 retval = WaitForSingleObject(shExecInfo.hProcess, INSTALL_TIMEOUT);
136
137 free((void*)shExecInfo.lpFile);
138 free((void*)shExecInfo.lpParameters);
139 shExecInfo.lpFile = NULL;
140 shExecInfo.lpParameters = NULL;
134 141
135 if (retval != WAIT_OBJECT_0) { 142 if (retval != WAIT_OBJECT_0) {
136 if (retval == WAIT_FAILED) { 143 if (retval == WAIT_FAILED) {
137 char* errmsg = getLastErrorMsg(); 144 char* errmsg = getLastErrorMsg();
138 QString qerrmsg = QString::fromUtf8(errmsg); 145 QString qerrmsg = QString::fromUtf8(errmsg);

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