Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 9d5c637

Browse files
committed
Load distro name and window caption from win32 resource
1 parent 0d44178 commit 9d5c637

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

DistroLauncher/DistributionInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
//
55

66
#include "stdafx.h"
7+
#include "resource.h"
8+
9+
static std::wstring_view LoadStringFromResource(UINT resId, std::wstring_view default)
10+
{
11+
wchar_t* res;
12+
int len = LoadStringW(GetModuleHandle(nullptr), resId, reinterpret_cast<LPWSTR>(&res), 0);
13+
return len ? std::wstring_view(res, len) : default;
14+
}
15+
16+
const std::wstring DistributionInfo::Name(LoadStringFromResource(IDS_DISTRO_NAME, L"Debian"));
17+
const std::wstring DistributionInfo::WindowTitle(LoadStringFromResource(IDS_WINDOW_CAPTION, L"Debian"));
18+
719

820
bool DistributionInfo::CreateUser(std::wstring_view userName)
921
{

DistroLauncher/DistributionInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ namespace DistributionInfo
1313
//
1414
// WARNING: This value must not change between versions of your app,
1515
// otherwise users upgrading from older versions will see launch failures.
16-
const std::wstring Name = L"Debian";
16+
extern const std::wstring Name;
1717

1818
// The title bar for the console window while the distribution is installing.
19-
const std::wstring WindowTitle = L"Debian";
19+
extern const std::wstring WindowTitle;
2020

2121
// Create and configure a user account.
2222
bool CreateUser(std::wstring_view userName);

DistroLauncher/DistroLauncher.rc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ END
5353
// remains consistent on all systems.
5454
IDI_ICON1 ICON ".\images\icon.ico"
5555

56+
/////////////////////////////////////////////////////////////////////////////
57+
//
58+
// String Table
59+
//
60+
61+
STRINGTABLE
62+
BEGIN
63+
IDS_DISTRO_NAME "Debian"
64+
IDS_WINDOW_CAPTION "Debian"
65+
END
66+
5667
#endif // English (United States) resources
5768
/////////////////////////////////////////////////////////////////////////////
5869

DistroLauncher/resource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Used by DistroInstaller.rc
44
//
55
#define IDI_ICON1 101
6+
#define IDS_DISTRO_NAME 150
7+
#define IDS_WINDOW_CAPTION 151
68

79
// Next default values for new objects
810
//

0 commit comments

Comments
 (0)