diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/apputil.cpp')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/apputil.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/apputil.cpp b/src/libs/dutil/WixToolset.DUtil/apputil.cpp index b70c8cfb..9e75082a 100644 --- a/src/libs/dutil/WixToolset.DUtil/apputil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/apputil.cpp | |||
@@ -87,31 +87,27 @@ DAPI_(HRESULT) LoadSystemLibraryWithPath( | |||
87 | ) | 87 | ) |
88 | { | 88 | { |
89 | HRESULT hr = S_OK; | 89 | HRESULT hr = S_OK; |
90 | DWORD cch = 0; | 90 | LPWSTR sczDirectory = NULL; |
91 | WCHAR wzPath[MAX_PATH] = { }; | 91 | LPWSTR sczPath = NULL; |
92 | 92 | ||
93 | cch = ::GetSystemDirectoryW(wzPath, MAX_PATH); | 93 | hr = PathGetSystemDirectory(&sczDirectory); |
94 | AppExitOnNullWithLastError(cch, hr, "Failed to get the Windows system directory."); | 94 | AppExitOnFailure(hr, "Failed to get the Windows system directory."); |
95 | 95 | ||
96 | if (L'\\' != wzPath[cch - 1]) | 96 | hr = StrAllocFormatted(&sczPath, L"%ls%ls", sczDirectory, wzModuleName); |
97 | { | 97 | AppExitOnFailure(hr, "Failed to create the fully-qualified path to %ls.", wzModuleName); |
98 | hr = ::StringCchCatNW(wzPath, MAX_PATH, L"\\", 1); | ||
99 | AppExitOnRootFailure(hr, "Failed to terminate the string with a backslash."); | ||
100 | } | ||
101 | 98 | ||
102 | hr = ::StringCchCatW(wzPath, MAX_PATH, wzModuleName); | 99 | *phModule = ::LoadLibraryExW(sczPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); |
103 | AppExitOnRootFailure(hr, "Failed to create the fully-qualified path to %ls.", wzModuleName); | 100 | AppExitOnNullWithLastError(*phModule, hr, "Failed to load the library %ls.", sczPath); |
104 | |||
105 | *phModule = ::LoadLibraryExW(wzPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); | ||
106 | AppExitOnNullWithLastError(*phModule, hr, "Failed to load the library %ls.", wzModuleName); | ||
107 | 101 | ||
108 | if (psczPath) | 102 | if (psczPath) |
109 | { | 103 | { |
110 | hr = StrAllocString(psczPath, wzPath, MAX_PATH); | 104 | *psczPath = sczPath; |
111 | AppExitOnFailure(hr, "Failed to copy the path to library."); | 105 | sczPath = NULL; |
112 | } | 106 | } |
113 | 107 | ||
114 | LExit: | 108 | LExit: |
109 | ReleaseStr(sczDirectory); | ||
110 | |||
115 | return hr; | 111 | return hr; |
116 | } | 112 | } |
117 | 113 | ||