Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Dialog OS Version #3696

Closed
wants to merge 10 commits into from
5 changes: 4 additions & 1 deletion src/cascadia/TerminalApp/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Temporarily using the Windows Terminal default settings.
<value>About</value>
</data>
<data name="VersionLabelText" xml:space="preserve">
<value>Version:</value>
<value>WT Version:</value>
Copy link
Member

@zadjii-msft zadjii-msft Nov 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd personally leave this unchanged, but maybe that's a personal stylistic choice. @DHowett-MSFT /@cinnamon-msft do you have thoughts here?

(TBH you don't need to change this back unless someone else agrees with me here)

</data>
<data name="DocumentationLabelText" xml:space="preserve">
<value>Documentation
Expand Down Expand Up @@ -210,4 +210,7 @@ Temporarily using the Windows Terminal default settings.
<data name="CloseWindowWarningTitle" xml:space="preserve">
<value>Do you want to close all tabs?</value>
</data>
<data name="OsVersionLabelText" xml:space="preserve">
<value>OS Version:</value>
</data>
</root>
59 changes: 58 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,57 @@ namespace winrt::TerminalApp::implementation
_showDialogHandlers(*this, dialog);
}

// Method Description:
// - Implements the MSDN suggested method of obtaining the full OS version number
// https://docs.microsoft.com/en-us/windows/win32/sysinfo/getting-the-system-version
// - On failure the output wstring will be L"0.0.0.0"
std::wstring TerminalPage::_GetWindowsVersion()
{
const auto dll{ L"KernelBase.dll" };
DWORD fill{};
const auto infoSize{ GetFileVersionInfoSizeExW(FILE_VER_GET_NEUTRAL, dll, &fill) };
auto buffer{ wil::make_unique_nothrow<BYTE[]>(infoSize) };
// clear variables for use in case of failure
WORD osMaj{}, osMin{}, osBld{}, osRev{};

if (GetFileVersionInfoExW(FILE_VER_GET_NEUTRAL, dll, fill, infoSize, buffer.get()))
{
VS_FIXEDFILEINFO* versionInfo{ nullptr };
UINT size{};

if (VerQueryValueW(buffer.get(), L"\\", (LPVOID*)&versionInfo, &size))
{
osMaj = HIWORD(versionInfo->dwProductVersionMS);
osMin = LOWORD(versionInfo->dwProductVersionMS);
osBld = HIWORD(versionInfo->dwProductVersionLS);
osRev = LOWORD(versionInfo->dwProductVersionLS);
}
}

SYSTEM_INFO sysInfo{};
std::wstring arch{ L"Unknown" };
GetSystemInfo(&sysInfo);

switch (sysInfo.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_AMD64:
arch = L"x64";
break;
case PROCESSOR_ARCHITECTURE_ARM64:
arch = L"ARM64";
break;
case PROCESSOR_ARCHITECTURE_INTEL:
arch = L"x86";
break;
default:
break;
}

std::wstringstream osVersionStream{};
osVersionStream << osMaj << L"." << osMin << L"." << osBld << L"." << osRev << L" " << arch;
return osVersionStream.str();
}

// Method Description:
// - Show a dialog with "About" information. Displays the app's Display
// Name, version, getting started link, documentation link, and release
Expand All @@ -161,6 +212,7 @@ namespace winrt::TerminalApp::implementation
{
const auto title = RS_(L"AboutTitleText");
const auto versionLabel = RS_(L"VersionLabelText");
const auto osVersionLabel = RS_(L"OsVersionLabelText");
const auto gettingStartedLabel = RS_(L"GettingStartedLabelText");
const auto documentationLabel = RS_(L"DocumentationLabelText");
const auto releaseNotesLabel = RS_(L"ReleaseNotesLabelText");
Expand All @@ -170,6 +222,8 @@ namespace winrt::TerminalApp::implementation
const auto package = winrt::Windows::ApplicationModel::Package::Current();
const auto packageName = package.DisplayName();
const auto version = package.Id().Version();
const auto osVersion = _GetWindowsVersion();

winrt::Windows::UI::Xaml::Documents::Run about;
winrt::Windows::UI::Xaml::Documents::Run gettingStarted;
winrt::Windows::UI::Xaml::Documents::Run documentation;
Expand Down Expand Up @@ -197,7 +251,8 @@ namespace winrt::TerminalApp::implementation

// Format our about text. It will look like the following:
// <Display Name>
// Version: <Major>.<Minor>.<Build>.<Revision>
// WT Version: <WtMajor>.<WtMinor>.<WtBuild>.<WtRevision>
// OS Version: <OsMajor>.<OsMinor>.<OsBuild>.<OsRevision> <CpuArch>
// Getting Started
// Documentation
// Release Notes
Expand All @@ -207,6 +262,8 @@ namespace winrt::TerminalApp::implementation
aboutTextStream << versionLabel.c_str() << L" ";
aboutTextStream << version.Major << L"." << version.Minor << L"." << version.Build << L"." << version.Revision << L"\n";

aboutTextStream << osVersionLabel.c_str() << L" " << osVersion.c_str() << L"\n";

winrt::hstring aboutText{ aboutTextStream.str() };
about.Text(aboutText);

Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ namespace winrt::TerminalApp::implementation
std::optional<int> _rearrangeFrom;
std::optional<int> _rearrangeTo;

std::wstring _GetWindowsVersion();

winrt::com_ptr<ShortcutActionDispatch> _actionDispatch{ winrt::make_self<ShortcutActionDispatch>() };

void _ShowAboutDialog();
Expand Down