diff options
Diffstat (limited to 'src/ext/Bal/stdbas/stdbas.cpp')
| -rw-r--r-- | src/ext/Bal/stdbas/stdbas.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/ext/Bal/stdbas/stdbas.cpp b/src/ext/Bal/stdbas/stdbas.cpp new file mode 100644 index 00000000..909bdc23 --- /dev/null +++ b/src/ext/Bal/stdbas/stdbas.cpp | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | |||
| 5 | static const LPCWSTR WIX_BUNDLE_ICON_FILENAME = L"WixBundle.ico"; | ||
| 6 | |||
| 7 | |||
| 8 | // | ||
| 9 | // LoadBundleIcon - loads the icon that was (optionally) authored in the bundle otherwise use the one embedded in the bootstrapper application. | ||
| 10 | // | ||
| 11 | HRESULT LoadBundleIcon( | ||
| 12 | __in HMODULE hModule, | ||
| 13 | __out HICON* phIcon, | ||
| 14 | __out HICON* phSmallIcon | ||
| 15 | ) | ||
| 16 | { | ||
| 17 | HRESULT hr = S_OK; | ||
| 18 | LPWSTR sczIconPath = NULL; | ||
| 19 | int nIconWidth = ::GetSystemMetrics(SM_CXICON); | ||
| 20 | int nIconHeight = ::GetSystemMetrics(SM_CYICON); | ||
| 21 | int nSmallIconWidth = ::GetSystemMetrics(SM_CXSMICON); | ||
| 22 | int nSmallIconHeight = ::GetSystemMetrics(SM_CYSMICON); | ||
| 23 | HICON hIcon = NULL; | ||
| 24 | HICON hSmallIcon = NULL; | ||
| 25 | |||
| 26 | // First look for the optional authored bundle icon. | ||
| 27 | hr = PathRelativeToModule(&sczIconPath, WIX_BUNDLE_ICON_FILENAME, hModule); | ||
| 28 | ExitOnFailure(hr, "Failed to get path to bundle icon: %ls", WIX_BUNDLE_ICON_FILENAME); | ||
| 29 | |||
| 30 | if (FileExistsEx(sczIconPath, NULL)) | ||
| 31 | { | ||
| 32 | hIcon = reinterpret_cast<HICON>(::LoadImageW(NULL, sczIconPath, IMAGE_ICON, nIconWidth, nIconHeight, LR_LOADFROMFILE)); | ||
| 33 | |||
| 34 | hSmallIcon = reinterpret_cast<HICON>(::LoadImageW(NULL, sczIconPath, IMAGE_ICON, nSmallIconWidth, nSmallIconHeight, LR_LOADFROMFILE)); | ||
| 35 | } | ||
| 36 | else // fallback to the first icon resource in the bootstrapper application. | ||
| 37 | { | ||
| 38 | hIcon = reinterpret_cast<HICON>(::LoadImageW(hModule, MAKEINTRESOURCEW(1), IMAGE_ICON, nIconWidth, nIconHeight, LR_DEFAULTCOLOR)); | ||
| 39 | |||
| 40 | hSmallIcon = reinterpret_cast<HICON>(::LoadImageW(hModule, MAKEINTRESOURCEW(1), IMAGE_ICON, nSmallIconWidth, nSmallIconHeight, LR_DEFAULTCOLOR)); | ||
| 41 | } | ||
| 42 | |||
| 43 | *phIcon = hIcon; | ||
| 44 | *phSmallIcon = hSmallIcon; | ||
| 45 | |||
| 46 | LExit: | ||
| 47 | ReleaseStr(sczIconPath); | ||
| 48 | |||
| 49 | return hr; | ||
| 50 | } | ||
