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

Commit 1e594aa

Browse files
committed
Load distro name and window caption from win32 resource
1 parent 2ed9a93 commit 1e594aa

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

DistroLauncher/DistributionInfo.cpp

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

66
#include "stdafx.h"
7+
#include "resource.h"
8+
9+
static std::wstring_view LoadStringFromResource(UINT resId, std::wstring_view defaultStr)
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) : defaultStr;
14+
}
15+
16+
const std::wstring DistributionInfo::Name(LoadStringFromResource(IDS_DISTRO_NAME, L"MyDistribution"));
17+
const std::wstring DistributionInfo::WindowTitle(LoadStringFromResource(IDS_WINDOW_CAPTION, L"My Distribution"));
718

819
bool DistributionInfo::CreateUser(std::wstring_view userName)
920
{

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"MyDistribution";
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"My Distribution";
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: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,37 @@
1212
/////////////////////////////////////////////////////////////////////////////
1313
#undef APSTUDIO_READONLY_SYMBOLS
1414

15+
/////////////////////////////////////////////////////////////////////////////
16+
// Neutral resources
17+
18+
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
19+
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
20+
21+
/////////////////////////////////////////////////////////////////////////////
22+
//
23+
// Icon
24+
//
25+
26+
// Icon with lowest ID value placed first to ensure application icon
27+
// remains consistent on all systems.
28+
IDI_ICON1 ICON ".\\images\\icon.ico"
29+
30+
31+
/////////////////////////////////////////////////////////////////////////////
32+
//
33+
// String Table
34+
//
35+
36+
STRINGTABLE
37+
BEGIN
38+
IDS_DISTRO_NAME "MyDistribution"
39+
IDS_WINDOW_CAPTION "My Distribution"
40+
END
41+
42+
#endif // Neutral resources
43+
/////////////////////////////////////////////////////////////////////////////
44+
45+
1546
/////////////////////////////////////////////////////////////////////////////
1647
// English (United States) resources
1748

@@ -43,16 +74,6 @@ END
4374

4475
#endif // APSTUDIO_INVOKED
4576

46-
47-
/////////////////////////////////////////////////////////////////////////////
48-
//
49-
// Icon
50-
//
51-
52-
// Icon with lowest ID value placed first to ensure application icon
53-
// remains consistent on all systems.
54-
IDI_ICON1 ICON ".\images\icon.ico"
55-
5677
#endif // English (United States) resources
5778
/////////////////////////////////////////////////////////////////////////////
5879

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 151
7+
#define IDS_WINDOW_CAPTION 152
68

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

0 commit comments

Comments
 (0)