本文整理汇总了C++中Registry::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ Registry::Open方法的具体用法?C++ Registry::Open怎么用?C++ Registry::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry::Open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLocalProfiles
// Retrieves the account names (domain\user) for all local accounts
std::vector<UserProfile> GetLocalProfiles()
{
Registry reg;
DWORD ret = reg.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList", Registry::Mode::Read);
if (ret != ERROR_SUCCESS) throw SysError(ret);
std::vector<std::wstring> profileSids;
ret = reg.EnumKeys(profileSids);
if (ret != ERROR_SUCCESS) throw SysError(ret);
std::vector<UserProfile> accounts;
for (auto const& sidStr : profileSids)
{
UserProfile profile{};
profile.sid = sidStr;
Registry::TryReadString(reg.Key(), sidStr, L"ProfileImagePath", profile.path);
/*DWORD ret = */Security::SidToAccountName(sidStr, profile.name, profile.domain);
accounts.push_back(profile);
}
return accounts;
}
示例2: Init
DWORD Init()
{
Registry reg;
auto result = reg.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", Registry::Mode::Read);
if (result != ERROR_SUCCESS)
{
return result;
}
reg.TryReadString(L"CurrentBuildNumber", CurrentBuildNumber);
reg.TryReadDword(L"CurrentMajorVersionNumber", CurrentMajorVersionNumber);
reg.TryReadDword(L"CurrentMinorVersionNumber", CurrentMinorVersionNumber);
reg.TryReadString(L"CSDbuildNumber", CSDBuildNumber);
reg.TryReadString(L"CSDVersion", ServicePack);
auto pos = ServicePack.find_last_not_of(L"Service Pack ");
if (pos != std::wstring::npos)
{
ServicePack = L"SP" + ServicePack.substr(pos);
}
if (reg.TryReadString(L"BuildLabEx", BuildLabEx) != NO_ERROR)
{
reg.TryReadString(L"BuildLab", BuildLabEx);
}
reg.TryReadString(L"CurrentVersion", CurrentVersion);
reg.TryReadString(L"EditionId", EditionId);
reg.TryReadString(L"ProductName", ProductName);
if (CurrentMajorVersionNumber > 0)
{
CurrentVersion = std::to_wstring(CurrentMajorVersionNumber) + L"." + std::to_wstring(CurrentMinorVersionNumber);
}
else
{
reg.TryReadString(L"CurrentVersion", CurrentVersion);
}
Architecture = IsX64() ? std::wstring(L"x64") : std::wstring(L"x86");
Language = GetDefaultLocaleName();
return ERROR_SUCCESS;
}