mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
switch to use policy manager apis for detecting graphing policy
This commit is contained in:
parent
e6b30fa295
commit
4ed6e8727c
2 changed files with 10 additions and 19 deletions
|
@ -9,10 +9,13 @@
|
|||
|
||||
using namespace CalculatorApp;
|
||||
using namespace CalculatorApp::Common;
|
||||
using namespace Concurrency;
|
||||
using namespace Platform;
|
||||
using namespace Platform::Collections;
|
||||
using namespace std;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
using namespace Windows::Management::Policies;
|
||||
using namespace Windows::System;
|
||||
|
||||
namespace UCM = UnitConversionManager;
|
||||
|
||||
|
@ -85,25 +88,12 @@ bool IsGraphingModeEnabled()
|
|||
return _isGraphingModeEnabledCached->Value;
|
||||
}
|
||||
|
||||
DWORD allowGraphingCalculator{ 0 };
|
||||
DWORD bufferSize{ sizeof(allowGraphingCalculator) };
|
||||
// Make sure to call RegGetValueW only on Windows 10 1903+
|
||||
if (RegGetValueW(
|
||||
HKEY_CURRENT_USER,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Calculator",
|
||||
L"AllowGraphingCalculator",
|
||||
RRF_RT_DWORD, // RRF_RT_DWORD == RRF_RT_REG_DWORD | RRF_RT_REG_BINARY
|
||||
nullptr,
|
||||
reinterpret_cast<LPBYTE>(&allowGraphingCalculator),
|
||||
&bufferSize)
|
||||
== ERROR_SUCCESS)
|
||||
{
|
||||
_isGraphingModeEnabledCached = allowGraphingCalculator != 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isGraphingModeEnabledCached = true;
|
||||
}
|
||||
User ^ firstUser;
|
||||
create_task(User::FindAllAsync(UserType::LocalUser)).then([&firstUser](IVectorView<User ^> ^ users) {
|
||||
firstUser = users->GetAt(0); }).wait();
|
||||
auto namedPolicyData = NamedPolicy::GetPolicyFromPathForUser(firstUser, L"Education", L"AllowGraphingCalculator");
|
||||
_isGraphingModeEnabledCached = namedPolicyData->GetBoolean() == true;
|
||||
|
||||
return _isGraphingModeEnabledCached->Value;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "winrt/Windows.System.UserProfile.h"
|
||||
#include "winrt/Windows.UI.Xaml.h"
|
||||
#include "winrt/Windows.Foundation.Metadata.h"
|
||||
#include "winrt/Windows.Management.Policies.h"
|
||||
|
||||
// The following namespaces exist as a convenience to resolve
|
||||
// ambiguity for Windows types in the Windows::UI::Xaml::Automation::Peers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue