🔧 Make it actually work
This commit is contained in:
parent
b4b729609a
commit
f62e0a4ed4
1 changed files with 20 additions and 7 deletions
|
@ -156,12 +156,14 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||||
base::string16 keyPath = L"Software\\Classes\\";
|
base::string16 keyPath = L"Software\\Classes\\";
|
||||||
|
|
||||||
// Command Key
|
// Command Key
|
||||||
base::string16 protocol16 = base::UTF8ToUTF16(protocol);
|
base::string16 wprotocol = base::UTF8ToUTF16(protocol);
|
||||||
base::string16 cmdPath = keyPath + protocol16 + L"\\shell\\open\\command";
|
base::string16 shellPath = wprotocol + L"\\shell";
|
||||||
|
base::string16 cmdPath = keyPath + shellPath + L"\\open\\command";
|
||||||
|
|
||||||
base::win::RegKey key;
|
base::win::RegKey classesKey;
|
||||||
base::win::RegKey commandKey;
|
base::win::RegKey commandKey;
|
||||||
if (FAILED(key.Open(root, keyPath.c_str(), KEY_ALL_ACCESS)))
|
|
||||||
|
if (FAILED(classesKey.Open(root, keyPath.c_str(), KEY_ALL_ACCESS)))
|
||||||
// Classes key doesn't exist, that's concerning, but I guess we're not the default handler
|
// Classes key doesn't exist, that's concerning, but I guess we're not the default handler
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -180,11 +182,22 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||||
|
|
||||||
if (keyVal == exe) {
|
if (keyVal == exe) {
|
||||||
// Let's kill the key
|
// Let's kill the key
|
||||||
if (FAILED(key.DeleteKey(protocol16 + L"shell")))
|
if (FAILED(classesKey.DeleteKey(shellPath.c_str())))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If empty, delete
|
// Let's clean up after ourselves
|
||||||
key.DeleteEmptyKey(protocol16);
|
base::win::RegKey protocolKey;
|
||||||
|
base::string16 protocolPath = keyPath + wprotocol;
|
||||||
|
|
||||||
|
if (SUCCEEDED(protocolKey.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) {
|
||||||
|
protocolKey.DeleteValue(L"URL Protocol");
|
||||||
|
|
||||||
|
// Overwrite the default value to be empty, we can't delete it right away
|
||||||
|
protocolKey.WriteValue(L"", L"");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If now empty, delete the whole key
|
||||||
|
classesKey.DeleteEmptyKey(wprotocol.c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue