- Timestamp:
- Jul 4, 2011 1:54:00 PM (13 years ago)
- Location:
- trunk/src/VBox/Installer/win
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp
r37289 r37765 63 63 static void LogString(MSIHANDLE hInstall, LPCSTR szString, ...) 64 64 { 65 PMSIHANDLE newHandle = ::MsiCreateRecord(2);65 PMSIHANDLE newHandle = MsiCreateRecord(2); 66 66 67 67 char szBuffer[1024] = {0}; … … 82 82 static void LogStringW(MSIHANDLE hInstall, LPCWSTR szString, ...) 83 83 { 84 PMSIHANDLE newHandle = ::MsiCreateRecord(2);84 PMSIHANDLE newHandle = MsiCreateRecord(2); 85 85 86 86 TCHAR szBuffer[1024] = {0}; … … 111 111 } 112 112 113 DWORD Exec(MSIHANDLE hModule, TCHAR* szAppName, TCHAR* szCmdLine, TCHAR* szWorkDir, DWORD* dwExitCode) 113 DWORD Exec(MSIHANDLE hModule, 114 const TCHAR *pszAppName, TCHAR *pszCmdLine, const TCHAR *pszWorkDir, 115 DWORD *pdwExitCode) 114 116 { 115 117 STARTUPINFO si; … … 117 119 DWORD rc = ERROR_SUCCESS; 118 120 119 ::ZeroMemory(&si, sizeof(si));121 ZeroMemory(&si, sizeof(si)); 120 122 si.dwFlags = STARTF_USESHOWWINDOW; 121 123 #ifdef UNICODE … … 124 126 si.wShowWindow = SW_HIDE; /* For debugging: SW_SHOW; */ 125 127 si.cb = sizeof(si); 126 ::ZeroMemory(&pi, sizeof(pi));128 ZeroMemory(&pi, sizeof(pi)); 127 129 128 130 LogStringW(hModule, TEXT("Executing command line: %s %s (Working Dir: %s)"), 129 szAppName, szCmdLine, szWorkDir == NULL ? L"Current" :szWorkDir);130 131 ::SetLastError(0);132 if (! ::CreateProcess(szAppName, /* Module name. */133 134 135 136 137 138 139 140 141 142 { 143 rc = ::GetLastError();131 pszAppName, pszCmdLine, pszWorkDir == NULL ? L"Current" : pszWorkDir); 132 133 SetLastError(0); 134 if (!CreateProcess(pszAppName, /* Module name. */ 135 pszCmdLine, /* Command line. */ 136 NULL, /* Process handle not inheritable. */ 137 NULL, /* Thread handle not inheritable. */ 138 FALSE, /* Set handle inheritance to FALSE .*/ 139 0, /* No creation flags. */ 140 NULL, /* Use parent's environment block. */ 141 pszWorkDir, /* Use parent's starting directory. */ 142 &si, /* Pointer to STARTUPINFO structure. */ 143 &pi)) /* Pointer to PROCESS_INFORMATION structure. */ 144 { 145 rc = GetLastError(); 144 146 LogStringW(hModule, TEXT("Executing command line: CreateProcess() failed! Error: %ld"), rc); 145 147 return rc; … … 147 149 148 150 /* Wait until child process exits. */ 149 if (WAIT_FAILED == ::WaitForSingleObject(pi.hProcess, 30 * 1000 /* Wait 30 secs max. */))150 { 151 rc = ::GetLastError();151 if (WAIT_FAILED == WaitForSingleObject(pi.hProcess, 30 * 1000 /* Wait 30 secs max. */)) 152 { 153 rc = GetLastError(); 152 154 LogStringW(hModule, TEXT("Executing command line: WaitForSingleObject() failed! Error: %ld"), rc); 153 155 } 154 156 else 155 157 { 156 if ( 0 == ::GetExitCodeProcess(pi.hProcess,dwExitCode))157 { 158 rc = ::GetLastError();158 if (!GetExitCodeProcess(pi.hProcess, pdwExitCode)) 159 { 160 rc = GetLastError(); 159 161 LogStringW(hModule, TEXT("Executing command line: GetExitCodeProcess() failed! Error: %ld"), rc); 160 162 } … … 162 164 163 165 /* Close process and thread handles. */ 164 ::CloseHandle(pi.hProcess);165 ::CloseHandle(pi.hThread);166 167 LogStringW(hModule, TEXT("Executing command returned: %ld (exit code %ld)"), rc, * dwExitCode);166 CloseHandle(pi.hProcess); 167 CloseHandle(pi.hThread); 168 169 LogStringW(hModule, TEXT("Executing command returned: %ld (exit code %ld)"), rc, *pdwExitCode); 168 170 return rc; 169 171 } … … 175 177 HKEY hkPythonCore = NULL; 176 178 BOOL bFound = FALSE; 177 LONG rc = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Python\\PythonCore", 0, KEY_READ, &hkPythonCore);179 LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Python\\PythonCore", 0, KEY_READ, &hkPythonCore); 178 180 if (rc != ERROR_SUCCESS) 179 181 { … … 191 193 DWORD dwKeyType = REG_SZ; 192 194 193 rc = ::RegEnumKeyEx(hkPythonCore, i, szRoot, &dwLen, NULL, NULL, NULL, NULL);195 rc = RegEnumKeyEx(hkPythonCore, i, szRoot, &dwLen, NULL, NULL, NULL, NULL); 194 196 if (rc != ERROR_SUCCESS || dwLen <= 0) 195 197 break; … … 199 201 200 202 HKEY hkPythonInstPath = NULL; 201 rc = ::RegOpenKeyEx(hkPythonCore, szPath, 0, KEY_READ, &hkPythonInstPath);203 rc = RegOpenKeyEx(hkPythonCore, szPath, 0, KEY_READ, &hkPythonInstPath); 202 204 if (rc != ERROR_SUCCESS) 203 205 continue; 204 206 205 rc = ::RegQueryValueEx(hkPythonInstPath, L"", NULL, &dwKeyType, (LPBYTE)szVal, &dwLen);207 rc = RegQueryValueEx(hkPythonInstPath, L"", NULL, &dwKeyType, (LPBYTE)szVal, &dwLen); 206 208 if (rc == ERROR_SUCCESS) 207 209 LogStringW(hModule, TEXT("InstallPythonAPI: Path \"%s\" detected."), szVal); 208 210 209 ::RegCloseKey(hkPythonInstPath);210 } 211 ::RegCloseKey(hkPythonCore);211 RegCloseKey(hkPythonInstPath); 212 } 213 RegCloseKey(hkPythonCore); 212 214 213 215 /* Python path found? */ … … 215 217 TCHAR szCmdLine[MAX_PATH] = { 0 }; 216 218 DWORD dwExitCode = 0; 217 if ( ::_tcslen(szVal) > 0)219 if (_tcslen(szVal) > 0) 218 220 { 219 221 /* Cool, check for installed Win32 extensions. */ … … 222 224 _stprintf_s(szCmdLine, sizeof(szCmdLine) / sizeof(TCHAR), L"%s\\python.exe -c \"import win32api\"", szVal); 223 225 224 if ( (0 == Exec(hModule, szExec, szCmdLine, NULL, &dwExitCode)) 225 && (0 == dwExitCode)) 226 DWORD dwRetExec = Exec(hModule, szExec, szCmdLine, NULL, &dwExitCode); 227 if ( (ERROR_SUCCESS == dwRetExec) 228 && ( 0 == dwExitCode)) 226 229 { 227 230 /* Did we get the correct error level (=0)? */ … … 229 232 bFound = TRUE; 230 233 } 231 else LogStringW(hModule, TEXT("InstallPythonAPI: Win32 extensions not found.")); 234 else 235 LogStringW(hModule, TEXT("InstallPythonAPI: Win32 extensions not found.")); 232 236 } 233 237 … … 236 240 { 237 241 /* Get the VBoxAPI setup string. */ 238 TCHAR szVBoxAPISetupPath[MAX_PATH] = {0}; 239 VBoxGetProperty(hModule, L"INSTALLDIR", szVBoxAPISetupPath, sizeof(szVBoxAPISetupPath)); 240 241 /* Set final path. */ 242 _stprintf_s(szPath, sizeof(szPath) / sizeof(TCHAR), L"%s\\sdk\\install", szVBoxAPISetupPath); 243 244 /* Install our API module. */ 245 _stprintf_s(szCmdLine, sizeof(szCmdLine) / sizeof(TCHAR), L"%s\\python.exe vboxapisetup.py install", szVal); 246 247 /* Set required environment variables. */ 248 if (!SetEnvironmentVariable(L"VBOX_INSTALL_PATH", szVBoxAPISetupPath)) 249 { 250 LogStringW(hModule, TEXT("InstallPythonAPI: Could set environment variable VBOX_INSTALL_PATH!")); 242 TCHAR szPathTargetDir[MAX_PATH] = {0}; 243 VBoxGetProperty(hModule, L"CustomActionData", szPathTargetDir, sizeof(szPathTargetDir)); 244 if (_tcslen(szPathTargetDir)) 245 { 246 247 /* Set final path. */ 248 _stprintf_s(szPath, sizeof(szPath) / sizeof(TCHAR), L"%s\\sdk\\install", szPathTargetDir); 249 250 /* Install our API module. */ 251 _stprintf_s(szCmdLine, sizeof(szCmdLine) / sizeof(TCHAR), L"%s\\python.exe vboxapisetup.py install", szVal); 252 253 /* Set required environment variables. */ 254 if (!SetEnvironmentVariable(L"VBOX_INSTALL_PATH", szPathTargetDir)) 255 { 256 LogStringW(hModule, TEXT("InstallPythonAPI: Could set environment variable VBOX_INSTALL_PATH!")); 257 } 258 else 259 { 260 DWORD dwRetExec = Exec(hModule, szExec, szCmdLine, szPath, &dwExitCode); 261 if ( (ERROR_SUCCESS == dwRetExec) 262 && ( 0 == dwExitCode)) 263 { 264 /* All done! */ 265 LogStringW(hModule, TEXT("InstallPythonAPI: VBoxAPI for Python successfully installed.")); 266 bInstalled = TRUE; 267 } 268 else 269 { 270 if (dwRetExec) 271 LogStringW(hModule, TEXT("InstallPythonAPI: Error while executing installation of VBox API: %ld"), dwRetExec); 272 else 273 LogStringW(hModule, TEXT("InstallPythonAPI: Python reported an error while installing VBox API: %ld"), dwExitCode); 274 } 275 } 251 276 } 252 277 else 253 { 254 if ( (0 == Exec(hModule, szExec, szCmdLine, szPath, &dwExitCode)) 255 && (0 == dwExitCode)) 256 { 257 /* All done! */ 258 LogStringW(hModule, TEXT("InstallPythonAPI: VBoxAPI for Python successfully installed.")); 259 bInstalled = TRUE; 260 } 261 else 262 LogStringW(hModule, TEXT("InstallPythonAPI: Error while installing VBox API: %ld"), dwExitCode); 263 } 278 LogStringW(hModule, TEXT("InstallPythonAPI: Unable to retrieve VBox installation path!")); 264 279 } 265 280 … … 409 424 TCHAR szPathDest[_MAX_PATH]; 410 425 411 rc = VBoxGetProperty(hModule, L" INSTALLDIR", szPathTargetDir, sizeof(szPathTargetDir));426 rc = VBoxGetProperty(hModule, L"CustomActionData", szPathTargetDir, sizeof(szPathTargetDir)); 412 427 if (rc == ERROR_SUCCESS) 413 428 { … … 441 456 if (rc == ERROR_SUCCESS) 442 457 { 443 rc = VBoxGetProperty(hModule, L" INSTALLDIR", szPathTargetDir, sizeof(szPathTargetDir));458 rc = VBoxGetProperty(hModule, L"CustomActionData", szPathTargetDir, sizeof(szPathTargetDir)); 444 459 if (rc == ERROR_SUCCESS) 445 460 { -
trunk/src/VBox/Installer/win/VirtualBox.wxs
r37549 r37765 162 162 <Binary Id="VBoxInstallHelper" SourceFile="$(env.PATH_OUT)\bin\VBoxInstallHelper.dll" /> 163 163 <CustomAction Id="ca_CheckSerial" BinaryKey="VBoxInstallHelper" DllEntry="CheckSerial" Impersonate="no"/> 164 <CustomAction Id="ca_InstallPythonAPI" BinaryKey="VBoxInstallHelper" DllEntry="InstallPythonAPI" Execute="deferred" Impersonate="no"/> 165 <CustomAction Id="ca_InstallBranding" BinaryKey="VBoxInstallHelper" DllEntry="InstallBranding" Execute="deferred" Impersonate="no"/> 166 <CustomAction Id="ca_UninstallBranding" BinaryKey="VBoxInstallHelper" DllEntry="UninstallBranding" Execute="deferred" Impersonate="no"/> 164 165 <CustomAction Id="ca_InstallPythonAPI" BinaryKey="VBoxInstallHelper" DllEntry="InstallPythonAPI" Execute="deferred" Return="check" Impersonate="no"/> 166 <CustomAction Id="ca_InstallPythonAPIArgs" Property="ca_InstallPythonAPI" Value="[INSTALLDIR]" Execute="immediate"/> 167 168 <CustomAction Id="ca_InstallBranding" BinaryKey="VBoxInstallHelper" DllEntry="InstallBranding" Execute="deferred" Return="check" Impersonate="no"/> 169 <CustomAction Id="ca_InstallBrandingArgs" Property="ca_InstallBranding" Value="[INSTALLDIR]" Execute="immediate"/> 170 171 <CustomAction Id="ca_UninstallBranding" BinaryKey="VBoxInstallHelper" DllEntry="UninstallBranding" Execute="deferred" Return="check" Impersonate="no"/> 172 <CustomAction Id="ca_UninstallBrandingArgs" Property="ca_UninstallBranding" Value="[INSTALLDIR]" Execute="immediate"/> 167 173 168 174 <CustomAction Id="ca_UninstallTAPInstances" BinaryKey="VBoxInstallHelper" … … 170 176 171 177 <?if $(env.VBOX_WITH_NETFLT) = "yes" ?> 178 <CustomAction Id="ca_CreateHostOnlyInterface" BinaryKey="VBoxInstallHelper" DllEntry="CreateHostOnlyInterface" Execute="deferred" Return="check" Impersonate="no"/> 172 179 <CustomAction Id="ca_CreateHostOnlyInterfaceArgs" Property="ca_CreateHostOnlyInterface" Value="[INSTALLDIR]" Execute="immediate"/> 173 <CustomAction Id="ca_CreateHostOnlyInterface" BinaryKey="VBoxInstallHelper" DllEntry="CreateHostOnlyInterface" Execute="deferred" Return="check" Impersonate="no"/>174 180 175 181 <CustomAction Id="ca_RemoveHostOnlyInterfaces" BinaryKey="VBoxInstallHelper" DllEntry="RemoveHostOnlyInterfaces" Execute="deferred" Return="check" Impersonate="no"/> … … 724 730 725 731 <?if $(env.VBOX_WITH_PYTHON) = "yes" ?> 726 <Feature Id="ft_VBoxPython" Title="VirtualBox Python Support" Level="1"732 <Feature Id="ft_VBoxPython" Title="VirtualBox Python 2.x Support" Level="1" 727 733 Description="!(loc.VB_Python)" 728 734 ConfigurableDirectory="INSTALLDIR" TypicalDefault="install" Display="expand" > … … 762 768 <Custom Action="ca_UninstallNetFlt" After="InstallInitialize" ><![CDATA[&ft_VBoxNetworkFlt=2]]></Custom> 763 769 <?endif?> 770 <Custom Action="ca_InstallPythonAPIArgs" Before="ca_InstallPythonAPI" ><![CDATA[&ft_VBoxPython=3]]></Custom> 764 771 <Custom Action="ca_InstallPythonAPI" Before="InstallFinalize" ><![CDATA[&ft_VBoxPython=3]]></Custom> 772 773 <Custom Action="ca_InstallBrandingArgs" Before="ca_InstallBranding" ><![CDATA[NOT REMOVE]]></Custom> 765 774 <Custom Action="ca_InstallBranding" Before="InstallFinalize" ><![CDATA[NOT REMOVE]]></Custom> 775 776 <Custom Action="ca_UninstallBrandingArgs" Before="ca_UninstallBranding" ><![CDATA[REMOVE]]></Custom> 766 777 <Custom Action="ca_UninstallBranding" Before="InstallFinalize" ><![CDATA[REMOVE]]></Custom> 767 778
Note:
See TracChangeset
for help on using the changeset viewer.