RegistryHelper::splitKey

0 0 2025-05-29 本文地址:http://www.pnpon.com/fun/detail-35.html
wstring RegistryHelper::splitKey(const wstring& key, HKEY* rootKey)
{
    size_t pos = key.find(L'\\');
    if (pos == wstring::npos)
        throw RegistryException(L"Key " + key + L" has invalid format");

    wstring rootPart = key.substr(0, pos);
    wstring pathPart = key.substr(pos + 1);

    wstring p = StringHelper::toUpperCase(rootPart);
    if (p == L"HKEY_CLASSES_ROOT")
        *rootKey = HKEY_CLASSES_ROOT;
    else if (p == L"HKEY_CURRENT_CONFIG")
        *rootKey = HKEY_CURRENT_CONFIG;
    else if (p == L"HKEY_CURRENT_USER")
        *rootKey = HKEY_CURRENT_USER;
    else if (p == L"HKEY_LOCAL_MACHINE")
        *rootKey = HKEY_LOCAL_MACHINE;
    else if (p == L"HKEY_USERS")
        *rootKey = HKEY_USERS;
    else
        throw RegistryException(L"Unknown root key " + rootPart);

    return pathPart;
}
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!