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) {
|
||||
// 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);
|
||||
|
|
|
@ -32,18 +32,17 @@ namespace YYCC::DialogHelper {
|
|||
using SmartIShellItemArray = std::unique_ptr<IShellItemArray, ComPtrDeleter>;
|
||||
using SmartIShellFolder = std::unique_ptr<IShellFolder, ComPtrDeleter>;
|
||||
|
||||
template<typename _Ty>
|
||||
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<WCHAR, CoTaskMemDeleter<WCHAR>>;
|
||||
using SmartLPWSTR = std::unique_ptr<std::remove_pointer_t<LPWSTR>, CoTaskMemDeleter>;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user