From 4369e9e999a7b50d41af80adaf8138a7ae6e8550 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 7 Sep 2016 14:02:50 +0200 Subject: [PATCH] MsiUseFeature utility extended with installed language check --- MsiUseFeature/Main.cpp | 20 ++++++++++++++++++++ MsiUseFeature/MsiUseFeature.vcxproj | 5 +++++ MsiUseFeature/README.md | 6 ++++-- lib/WinStd | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/MsiUseFeature/Main.cpp b/MsiUseFeature/Main.cpp index e8c8f4b..77bc98a 100644 --- a/MsiUseFeature/Main.cpp +++ b/MsiUseFeature/Main.cpp @@ -52,6 +52,26 @@ static int MsiUseFeature() return 2; } + if (nArgs > 2) { + reg_key key; + if (!key.open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\") _T(VENDOR_NAME_STR) _T("\\") _T(PRODUCT_NAME_STR), 0, KEY_READ)) { + OutputDebugStr(_T("Product registry key cannot be opened (error %u).\n"), GetLastError()); + return 3; + } + + wstring lang; + LSTATUS s = RegQueryStringValue(key, _T("Language"), lang); + if (s != ERROR_SUCCESS) { + OutputDebugStr(_T("Error reading registry value (error %u).\n"), s); + return 3; + } + + if (_wcsicmp(pwcArglist[2], lang.c_str()) != 0) { + OutputDebugStr(_T("Different language (%ls, %ls).\n"), pwcArglist[2], lang.c_str()); + return 3; + } + } + return 0; } diff --git a/MsiUseFeature/MsiUseFeature.vcxproj b/MsiUseFeature/MsiUseFeature.vcxproj index abbe006..63f6744 100644 --- a/MsiUseFeature/MsiUseFeature.vcxproj +++ b/MsiUseFeature/MsiUseFeature.vcxproj @@ -100,6 +100,11 @@ + + + {47399d91-7eb9-41de-b521-514ba5db0c43} + + diff --git a/MsiUseFeature/README.md b/MsiUseFeature/README.md index 33bfbe1..c762008 100644 --- a/MsiUseFeature/README.md +++ b/MsiUseFeature/README.md @@ -3,15 +3,17 @@ Checks the installation state of the given feature of G ##Usage ``` -MsiUseFeature +MsiUseFeature [language] ``` - `feature name` - The name of the feature to check (i.e. "featEAPTTLS"; see Feature table of product MSI file) +- `language` - The user preferred language of the product Note: The MSI product code changes on every release. Therefore, `MsiUseFeature` utility with identical version should be used. Return codes: - -1 = Invalid parameters - 0 = Success -- 1 = The product is not installed or feature state is unknown +- 1 = The product is not installed, or feature state is unknown - 2 = The feature is not installed locally +- 3 = The installed user preferred language is different diff --git a/lib/WinStd b/lib/WinStd index 3948924..983bcbf 160000 --- a/lib/WinStd +++ b/lib/WinStd @@ -1 +1 @@ -Subproject commit 3948924124385430fd86e5c986d2f2c7c20f0c86 +Subproject commit 983bcbf9a2b0d9429b32aabf09efcbef9b73eef2