Fix bundled Universal CRT not working on computers where the Universal CRT was not already installed

This commit is contained in:
Kovid Goyal 2015-12-11 11:16:09 +05:30
parent 107c454cb2
commit ed1caccac7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 8 deletions

View File

@ -730,14 +730,17 @@ class Win32Freeze(Command, WixMixIn):
vc_path = os.path.join(r'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist', plat, 'Microsoft.VC140.CRT')
if not os.path.exists(vc_path):
raise SystemExit('Visual Studio redistributable CRT not found')
# I cannot get app local deployment of the UCRT to work. Things left to
# try: try dlls from the windows sdk standalone, try manually loading
# ucrtbase.dll and some api dlls before loading the launcher.
# sdk_path = os.path.join(r'C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs', plat)
# if not os.path.exists(sdk_path):
# raise SystemExit('Windows 10 redistributable CRT not found')
# for dll in glob.glob(os.path.join(sdk_path, '*.dll')):
# shutil.copy2(dll, self.dll_dir)
# We cannot use the Universal CRT DLLs that come with Visual Studio, as
# they are broken. Have to use the ones from the Standalone SDK for Windows 10.
# However, I dont want to install this SDK, incase it messes things up,
# so the below path points to dlls I got from installing the SDK in a
# different VM. To re-create just copy the api-ms*.dll and ucrtbase.dll
# files from a previous calibre install.
sdk_path = os.path.join(SW, '..', 'ucrt', 'DLLs', plat)
if not os.path.exists(sdk_path):
raise SystemExit('Windows 10 Universal CRT redistributable not found')
for dll in glob.glob(os.path.join(sdk_path, '*.dll')):
shutil.copy2(dll, self.dll_dir)
for dll in glob.glob(os.path.join(vc_path, '*.dll')):
bname = os.path.basename(dll)
if not bname.startswith('vccorlib') and not bname.startswith('concrt'):

View File

@ -78,6 +78,8 @@ static ENTRYPROC load_launcher_dll() {
show_last_error(L"Failed to set DLL directory");
return NULL;
}
// Have to load ucrtbase manually first, otherwise loading fails on systems where the
// Universal CRT is not installed.
if (!LoadLibraryW(L"ucrtbase.dll")) {
show_last_error(L"Unable to find ucrtbase.dll. You should install all Windows updates on your computer to get this file.");
return NULL;