| 61 | } |
| 62 | |
| 63 | bool ConfigManager::TryOpenConfigAsJson() noexcept |
| 64 | { |
| 65 | wil::unique_hkey key; |
| 66 | const HRESULT hr = AssocQueryKey(ASSOCF_VERIFY | ASSOCF_INIT_IGNOREUNKNOWN, ASSOCKEY_SHELLEXECCLASS, L".json", L"open", key.put()); |
| 67 | if (SUCCEEDED(hr)) |
| 68 | { |
| 69 | SHELLEXECUTEINFO info = { |
| 70 | .cbSize = sizeof(info), |
| 71 | .fMask = SEE_MASK_CLASSKEY | SEE_MASK_FLAG_NO_UI, |
| 72 | .lpVerb = L"open", |
| 73 | .lpFile = m_ConfigPath.c_str(), |
| 74 | .nShow = SW_SHOW, |
| 75 | .hkeyClass = key.get() |
| 76 | }; |
| 77 | |
| 78 | const bool success = ShellExecuteEx(&info); |
| 79 | if (!success) |
| 80 | { |
| 81 | LastErrorHandle(spdlog::level::warn, L"Failed to launch JSON file editor"); |
| 82 | } |
| 83 | |
| 84 | return success; |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | if (hr != HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION)) |
| 89 | { |
| 90 | HresultHandle(hr, spdlog::level::warn, L"Failed to query for .json file association"); |
| 91 | } |
| 92 | |
| 93 | return false; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | void ConfigManager::SaveToFile(FILE *f) const |
| 98 | { |