@@ -153,6 +153,13 @@ char *failure_reason = NULL;
153153HANDLE hBitmap ;
154154char * bitmap_bytes ;
155155
156+ static const char * REGISTRY_SUFFIX_6432 =
157+ #ifdef MS_WIN64
158+ "" ;
159+ #else
160+ "-32" ;
161+ #endif
162+
156163
157164#define WM_NUMFILES WM_USER+1
158165/* wParam: 0, lParam: total number of files */
@@ -657,16 +664,18 @@ static HINSTANCE LoadPythonDll(char *fname)
657664 if (h )
658665 return h ;
659666 wsprintf (subkey_name ,
660- "SOFTWARE\\Python\\PythonCore\\%d.%d\\InstallPath" ,
661- py_major , py_minor );
667+ "SOFTWARE\\Python\\PythonCore\\%d.%d%s \\InstallPath" ,
668+ py_major , py_minor , REGISTRY_SUFFIX_6432 );
662669 if (ERROR_SUCCESS != RegQueryValue (HKEY_CURRENT_USER , subkey_name ,
663670 fullpath , & size ) &&
664671 ERROR_SUCCESS != RegQueryValue (HKEY_LOCAL_MACHINE , subkey_name ,
665672 fullpath , & size ))
666673 return NULL ;
667674 strcat (fullpath , "\\" );
668675 strcat (fullpath , fname );
669- return LoadLibrary (fullpath );
676+ // We use LOAD_WITH_ALTERED_SEARCH_PATH to ensure any dependent DLLs
677+ // next to the Python DLL (eg, the CRT DLL) are also loaded.
678+ return LoadLibraryEx (fullpath , NULL , LOAD_WITH_ALTERED_SEARCH_PATH );
670679}
671680
672681static int prepare_script_environment (HINSTANCE hPython )
@@ -2250,6 +2259,8 @@ int DoInstall(void)
22502259 GetPrivateProfileString ("Setup" , "user_access_control" , "" ,
22512260 user_access_control , sizeof (user_access_control ), ini_file );
22522261
2262+ strcat (target_version , REGISTRY_SUFFIX_6432 );
2263+
22532264 // See if we need to do the Vista UAC magic.
22542265 if (strcmp (user_access_control , "force" )== 0 ) {
22552266 if (!MyIsUserAnAdmin ()) {
0 commit comments