HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
shlobj_core.hpp
1// Copyright Take Vos 2023.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
8#include "hresult_error_intf.hpp"
9#include <expected>
10#include <string>
11#include <system_error>
12#include <filesystem>
13
14hi_export_module(hikogui.win32 : shlobj_core);
15
16hi_export namespace hi {
17inline namespace v1 {
18
26[[nodiscard]] inline std::expected<std::filesystem::path, hresult_error> win32_SHGetKnownFolderPath(KNOWNFOLDERID const& folder_id) noexcept
27{
28 PWSTR wpath = nullptr;
29 auto const result_code = SHGetKnownFolderPath(folder_id, 0, nullptr, &wpath);
30
31 if (result_code != S_OK) {
32 return std::unexpected{static_cast<hresult_error>(result_code)};
33 }
34
35 auto r = std::filesystem::path{wpath} / "";
36 CoTaskMemFree(wpath);
37 return r;
38}
39
40} // namespace v1
41}
Rules for working with win32 headers.
The HikoGUI namespace.
Definition array_generic.hpp:20
std::expected< std::filesystem::path, hresult_error > win32_SHGetKnownFolderPath(KNOWNFOLDERID const &folder_id) noexcept
Convenience function for SHGetKnownFolderPath().
Definition shlobj_core.hpp:26
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
T unexpected(T... args)