From efcc371e3159d6337d1ce6733c774d5f50176c96 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Mon, 27 May 2024 19:48:25 +0800 Subject: [PATCH] fix: improve dialog helper - remove template for CoTaskMemDeleter due to previous confusion. - use std::remove_pointer_t instead of directly writting underlying type. --- src/DialogHelper.cpp | 2 +- src/DialogHelper.hpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/DialogHelper.cpp b/src/DialogHelper.cpp index b481e60..e789fd0 100644 --- a/src/DialogHelper.cpp +++ b/src/DialogHelper.cpp @@ -161,7 +161,7 @@ namespace YYCC::DialogHelper { bool ExtractDisplayName(IShellItem* item, std::string& ret) { // fetch display name from IShellItem* - WCHAR* _name; + LPWSTR _name; HRESULT hr = item->GetDisplayName(SIGDN_FILESYSPATH, &_name); if (FAILED(hr)) return false; SmartLPWSTR display_name(_name); diff --git a/src/DialogHelper.hpp b/src/DialogHelper.hpp index 109e4bc..6255930 100644 --- a/src/DialogHelper.hpp +++ b/src/DialogHelper.hpp @@ -32,18 +32,17 @@ namespace YYCC::DialogHelper { using SmartIShellItemArray = std::unique_ptr; using SmartIShellFolder = std::unique_ptr; - template class CoTaskMemDeleter { public: CoTaskMemDeleter() {} - void operator() (_Ty* com_ptr) { + void operator() (void* com_ptr) { if (com_ptr != nullptr) { CoTaskMemFree(com_ptr); } } }; - using SmartLPWSTR = std::unique_ptr>; + using SmartLPWSTR = std::unique_ptr, CoTaskMemDeleter>; #pragma endregion