WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
Shell.h
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 1991-2022 Amebis
4 Copyright © 2016 GÉANT
5*/
6
7#pragma once
8
9#include "Common.h"
10#include <Shlwapi.h>
11#include <string>
12
18
20template<class _Traits, class _Ax>
21static BOOL PathCanonicalizeA(_Inout_ std::basic_string<char, _Traits, _Ax> &sValue, _In_ LPCSTR pszPath)
22{
23 assert(0); // TODO: Test this code.
24
25 // Allocate buffer on heap and read into it.
26 char szBuffer[MAX_PATH + 1];
27 BOOL bResult = ::PathCanonicalizeA(szBuffer, pszPath);
28 sValue.assign(szBuffer, bResult ? MAX_PATH : 0);
29 return bResult;
30}
31
37template<class _Traits, class _Ax>
38static BOOL PathCanonicalizeW(_Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue, _In_ LPCWSTR pszPath)
39{
40 assert(0); // TODO: Test this code.
41
42 wchar_t szBuffer[MAX_PATH + 1];
43 BOOL bResult = ::PathCanonicalizeW(szBuffer, pszPath);
44 sValue.assign(szBuffer, bResult ? MAX_PATH : 0);
45 return bResult;
46}
47