aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal/stdbas/stdbas.cpp
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2026-01-06 22:59:35 -0800
committerRob Mensching <rob@firegiant.com>2026-01-07 16:25:33 -0800
commitb337ce4678a5c66c7a2edc2bf9f87a71b4916b1b (patch)
treea0d807245cd7019dde71051bd9e8de9a39e313a4 /src/ext/Bal/stdbas/stdbas.cpp
parent164ea64ea05c1298979cadda1842feaf86a1bda9 (diff)
downloadwix-main.tar.gz
wix-main.tar.bz2
wix-main.zip
Provide Bundle Icon in BA container and update wixstdba to use itHEADmain
Fixes 8104
Diffstat (limited to '')
-rw-r--r--src/ext/Bal/stdbas/stdbas.cpp50
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
5static 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//
11HRESULT 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
46LExit:
47 ReleaseStr(sczIconPath);
48
49 return hr;
50}