fix: improve dialog helper
- remove template for CoTaskMemDeleter due to previous confusion. - use std::remove_pointer_t instead of directly writting underlying type.
This commit is contained in:
parent
cebe2f004d
commit
efcc371e31
|
@ -161,7 +161,7 @@ namespace YYCC::DialogHelper {
|
||||||
|
|
||||||
bool ExtractDisplayName(IShellItem* item, std::string& ret) {
|
bool ExtractDisplayName(IShellItem* item, std::string& ret) {
|
||||||
// fetch display name from IShellItem*
|
// fetch display name from IShellItem*
|
||||||
WCHAR* _name;
|
LPWSTR _name;
|
||||||
HRESULT hr = item->GetDisplayName(SIGDN_FILESYSPATH, &_name);
|
HRESULT hr = item->GetDisplayName(SIGDN_FILESYSPATH, &_name);
|
||||||
if (FAILED(hr)) return false;
|
if (FAILED(hr)) return false;
|
||||||
SmartLPWSTR display_name(_name);
|
SmartLPWSTR display_name(_name);
|
||||||
|
|
|
@ -32,18 +32,17 @@ namespace YYCC::DialogHelper {
|
||||||
using SmartIShellItemArray = std::unique_ptr<IShellItemArray, ComPtrDeleter>;
|
using SmartIShellItemArray = std::unique_ptr<IShellItemArray, ComPtrDeleter>;
|
||||||
using SmartIShellFolder = std::unique_ptr<IShellFolder, ComPtrDeleter>;
|
using SmartIShellFolder = std::unique_ptr<IShellFolder, ComPtrDeleter>;
|
||||||
|
|
||||||
template<typename _Ty>
|
|
||||||
class CoTaskMemDeleter {
|
class CoTaskMemDeleter {
|
||||||
public:
|
public:
|
||||||
CoTaskMemDeleter() {}
|
CoTaskMemDeleter() {}
|
||||||
void operator() (_Ty* com_ptr) {
|
void operator() (void* com_ptr) {
|
||||||
if (com_ptr != nullptr) {
|
if (com_ptr != nullptr) {
|
||||||
CoTaskMemFree(com_ptr);
|
CoTaskMemFree(com_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using SmartLPWSTR = std::unique_ptr<WCHAR, CoTaskMemDeleter<WCHAR>>;
|
using SmartLPWSTR = std::unique_ptr<std::remove_pointer_t<LPWSTR>, CoTaskMemDeleter>;
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user