diff --git a/PC/bdist_wininst/bdist_wininst.vcxproj b/PC/bdist_wininst/bdist_wininst.vcxproj --- a/PC/bdist_wininst/bdist_wininst.vcxproj +++ b/PC/bdist_wininst/bdist_wininst.vcxproj @@ -65,16 +65,20 @@ $(OutDir)wininst.tlb MinSpace $(PySourcePath)Modules\zlib;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreaded + MultiThreadedDebug + MultiThreadedDebug + MultiThreaded $(PySourcePath)PC\bdist_wininst;%(AdditionalIncludeDirectories) comctl32.lib;imagehlp.lib;%(AdditionalDependencies) diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c --- a/PC/bdist_wininst/install.c +++ b/PC/bdist_wininst/install.c @@ -148,16 +148,23 @@ BOOL pyc_compile, pyo_compile; HKEY hkey_root = (HKEY)-1; BOOL success; /* Installation successful? */ char *failure_reason = NULL; HANDLE hBitmap; char *bitmap_bytes; +static const char *REGISTRY_SUFFIX_6432 = +#ifdef MS_WIN64 + ""; +#else + "-32"; +#endif + #define WM_NUMFILES WM_USER+1 /* wParam: 0, lParam: total number of files */ #define WM_NEXTFILE WM_USER+2 /* wParam: number of this file */ /* lParam: points to pathname */ static BOOL notify(int code, char *fmt, ...); @@ -652,23 +659,27 @@ static HINSTANCE LoadPythonDll(char *fna /* make sure PYTHONHOME is set, to that sys.path is initialized correctly */ wsprintf(buffer, "PYTHONHOME=%s", python_dir); _putenv(buffer); h = LoadLibrary(fname); if (h) return h; wsprintf(subkey_name, - "SOFTWARE\\Python\\PythonCore\\%d.%d\\InstallPath", - py_major, py_minor); + "SOFTWARE\\Python\\PythonCore\\%d.%d%s\\InstallPath", + py_major, py_minor, REGISTRY_SUFFIX_6432); if (ERROR_SUCCESS != RegQueryValue(HKEY_CURRENT_USER, subkey_name, fullpath, &size) && ERROR_SUCCESS != RegQueryValue(HKEY_LOCAL_MACHINE, subkey_name, fullpath, &size)) return NULL; + // The crt assembly is probably in the root of the install dir, so change + // to that directory before loading Python. + SetCurrentDirectory(fullpath); + // Tack on the DLL name and load it. strcat(fullpath, "\\"); strcat(fullpath, fname); return LoadLibrary(fullpath); } static int prepare_script_environment(HINSTANCE hPython) { PyObject *mod; @@ -2245,16 +2256,18 @@ int DoInstall(void) GetPrivateProfileString("Setup", "install_script", "", install_script, sizeof(install_script), ini_file); GetPrivateProfileString("Setup", "user_access_control", "", user_access_control, sizeof(user_access_control), ini_file); + strcat(target_version, REGISTRY_SUFFIX_6432); + // See if we need to do the Vista UAC magic. if (strcmp(user_access_control, "force")==0) { if (!MyIsUserAnAdmin()) { SpawnUAC(); return 0; } // already admin - keep going } else if (strcmp(user_access_control, "auto")==0) {