Требуется помощь с проблемой обработчика недвижимости [закрыто] ⇐ C++
Требуется помощь с проблемой обработчика недвижимости [закрыто]
I am currently working on a project involving property handlers, specifically targeting .txt files. As a newcomer to this field, I have encountered an issue that I'm struggling to resolve and would greatly appreciate your guidance.
My objective is to add a new page to the properties of a .txt file using a property handler. However, despite my efforts, the handler is not functioning as expected. I have implemented extensive logging in my source code to pinpoint the failure, but unfortunately, I have been unable to identify the root cause.
To provide more context, I have shared the relevant portion of my source code Here
Error happens at QueryInterface log file
DllGetClassObject called. QueryInterface called. Requested IID: {00000001-0000-0000-C000-000000000046} No matching interface was found. Release called.
this is the error I get when trying to debug with Visual Studio when I attach to the explorer.exe
Unhandled exception at 0x00007FFAC237DE84 (Microsoft.UI.Windowing.Core.dll) in explorer.exe: 0xC0000005: Access violation reading location 0x0000000000000030.
STDMETHODIMP_(ULONG) CMyPropertySheetHandler::AddRef() { LogMessage(L"AddRef: Reference count incremented to " + std::to_wstring(m_refCount)); return InterlockedIncrement(&m_refCount); } STDMETHODIMP_(ULONG) CMyPropertySheetHandler::Release() { ULONG refCount = InterlockedDecrement(&m_refCount); LogMessage(L"Release: Reference count decremented to " + std::to_wstring(refCount)); if (refCount == 0) { LogMessage(L"Release: Deleting the object."); delete this; } return refCount; } STDMETHODIMP CMyPropertySheetHandler::QueryInterface(REFIID riid, void** ppv) { if (ppv == nullptr) return E_POINTER; if (IsEqualIID(riid, IID_IUnknown)) { *ppv = static_cast(this); } else if (IsEqualIID(riid, __uuidof(IShellExtInit))) { *ppv = static_cast(this); } else if (IsEqualIID(riid, __uuidof(IShellPropSheetExt))) { *ppv = static_cast(this); } else if (IsEqualIID(riid, __uuidof(IClassFactory))) { *ppv = static_cast(this); } else { *ppv = nullptr; return E_NOINTERFACE; } AddRef(); // Increase reference count when returning interface pointer return S_OK; } HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { if (!IsEqualCLSID(rclsid, CLSID_MyPropertySheetHandler)) { // The CLSID does not match the CLSID of our shell extension return CLASS_E_CLASSNOTAVAILABLE; } CMyPropertySheetHandler* pClassFactory = new CMyPropertySheetHandler(); if (pClassFactory == nullptr) { return E_OUTOFMEMORY; } // Increment the reference count when returning the interface pointer ULONG refCount = pClassFactory->AddRef(); if (refCount == 1) { // We're transferring ownership to the caller, so no need to call Release *ppv = static_cast(pClassFactory); return S_OK; } else { // Decrement the reference count since we're not transferring ownership pClassFactory->Release(); return E_FAIL; } }
Источник: https://stackoverflow.com/questions/780 ... dler-issue
I am currently working on a project involving property handlers, specifically targeting .txt files. As a newcomer to this field, I have encountered an issue that I'm struggling to resolve and would greatly appreciate your guidance.
My objective is to add a new page to the properties of a .txt file using a property handler. However, despite my efforts, the handler is not functioning as expected. I have implemented extensive logging in my source code to pinpoint the failure, but unfortunately, I have been unable to identify the root cause.
To provide more context, I have shared the relevant portion of my source code Here
Error happens at QueryInterface log file
DllGetClassObject called. QueryInterface called. Requested IID: {00000001-0000-0000-C000-000000000046} No matching interface was found. Release called.
this is the error I get when trying to debug with Visual Studio when I attach to the explorer.exe
Unhandled exception at 0x00007FFAC237DE84 (Microsoft.UI.Windowing.Core.dll) in explorer.exe: 0xC0000005: Access violation reading location 0x0000000000000030.
STDMETHODIMP_(ULONG) CMyPropertySheetHandler::AddRef() { LogMessage(L"AddRef: Reference count incremented to " + std::to_wstring(m_refCount)); return InterlockedIncrement(&m_refCount); } STDMETHODIMP_(ULONG) CMyPropertySheetHandler::Release() { ULONG refCount = InterlockedDecrement(&m_refCount); LogMessage(L"Release: Reference count decremented to " + std::to_wstring(refCount)); if (refCount == 0) { LogMessage(L"Release: Deleting the object."); delete this; } return refCount; } STDMETHODIMP CMyPropertySheetHandler::QueryInterface(REFIID riid, void** ppv) { if (ppv == nullptr) return E_POINTER; if (IsEqualIID(riid, IID_IUnknown)) { *ppv = static_cast(this); } else if (IsEqualIID(riid, __uuidof(IShellExtInit))) { *ppv = static_cast(this); } else if (IsEqualIID(riid, __uuidof(IShellPropSheetExt))) { *ppv = static_cast(this); } else if (IsEqualIID(riid, __uuidof(IClassFactory))) { *ppv = static_cast(this); } else { *ppv = nullptr; return E_NOINTERFACE; } AddRef(); // Increase reference count when returning interface pointer return S_OK; } HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { if (!IsEqualCLSID(rclsid, CLSID_MyPropertySheetHandler)) { // The CLSID does not match the CLSID of our shell extension return CLASS_E_CLASSNOTAVAILABLE; } CMyPropertySheetHandler* pClassFactory = new CMyPropertySheetHandler(); if (pClassFactory == nullptr) { return E_OUTOFMEMORY; } // Increment the reference count when returning the interface pointer ULONG refCount = pClassFactory->AddRef(); if (refCount == 1) { // We're transferring ownership to the caller, so no need to call Release *ppv = static_cast(pClassFactory); return S_OK; } else { // Decrement the reference count since we're not transferring ownership pClassFactory->Release(); return E_FAIL; } }
Источник: https://stackoverflow.com/questions/780 ... dler-issue
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение