Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit f6819b6

Browse files
committed
Improved debug messages for PictThumbs.dll during registration/unregistration
1 parent 910e249 commit f6819b6

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

source/PictThumbs/regsetup.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "regutils.h"
66

77
HRESULT RegisterInprocServer(const std::wstring& clsid, const std::wstring& friendlyName) {
8+
Log << L"(Thumb): Register InprocServer\n";
89
WCHAR szModuleName[MAX_PATH];
910

1011
if (!GetModuleFileNameW(g_hInst, szModuleName, ARRAYSIZE(szModuleName))) {
@@ -15,42 +16,57 @@ HRESULT RegisterInprocServer(const std::wstring& clsid, const std::wstring& frie
1516
auto servKey = subKey + L"\\InProcServer32";
1617
HRESULT hr;
1718
hr = SetHkcrRegistryKeyAndValue(subKey, 0, friendlyName.c_str());
18-
if (FAILED(hr)) return hr;
19+
if (FAILED(hr)) {
20+
Log << L"(Thumb): Failed creating key/value for CLSID\n";
21+
return hr;
22+
}
1923

2024
hr = SetHkcrRegistryKeyAndValue(servKey, 0, szModuleName);
21-
if (FAILED(hr)) return hr;
25+
if (FAILED(hr)) {
26+
Log << L"(Thumb): Failed creating key/value for InProcServer32\n";
27+
return hr;
28+
}
2229

2330
hr = SetHkcrRegistryKeyAndValue(servKey, L"ThreadingModel", L"Apartment");
24-
if (FAILED(hr)) return hr;
31+
if (FAILED(hr)) {
32+
Log << L"(Thumb): Failed creating key/value for ThreadingModel\n";
33+
return hr;
34+
}
2535

2636
return hr;
2737
}
2838

2939
HRESULT RegisterThumbnailProvider(const std::wstring& clsId, const std::wstring& extension) {
3040
// We always register the shellex directly into the extension key.
3141
// This allows thumbnails to work for that format even when the user changes associations (progids).
42+
Log << L"(Thumb): Registering thumbnail provider for " << extension << L"\n";
3243

3344
auto currentSubKey = L"." + extension + L"\\shellex\\{e357fccd-a995-4576-b01f-234630154e96}";
3445
return SetHkcrRegistryKeyAndValue(currentSubKey, 0, clsId.c_str());
3546
}
3647

3748

3849
HRESULT UnregisterInprocServer(const std::wstring& clsid) {
50+
Log << L"(Thumb): Unregistering InprocServer\n";
3951
auto subKey = L"CLSID\\" + clsid;
4052

4153
return HRESULT_FROM_WIN32(RegDeleteTree(HKEY_CLASSES_ROOT, subKey.c_str()));
4254
}
4355

4456
HRESULT UnRegisterThumbnailProvider(const std::wstring& clsId, const std::wstring& extension) {
45-
// TODO: Verify that we are the current shellex for this extension!
57+
Log << L"(Thumb): Unregistering thumbnail provider for " << extension << L"\n";
58+
4659
auto currentSubKey = L"." + extension + L"\\shellex\\{e357fccd-a995-4576-b01f-234630154e96}";
4760

4861
auto ret = GetHkcrRegistryKeyAndValue(currentSubKey, 0);
4962
auto hr = std::get<0>(ret);
5063
auto currentClsId = std::get<1>(ret);
5164
if (FAILED(hr)) return hr; // Couldn't read value, that's an error
5265

53-
if (currentClsId != clsId) return S_OK; // Clsids didn't match. Not an error, but we shouldn't remove the key.
66+
if (currentClsId != clsId) {
67+
Log << L"(Thumb:UnRegisterThumbnailProvider): CLSID mismatch for " << extension << L", expected " << clsId << L" but got " << currentClsId << L"\n";
68+
return S_OK; // Clsids didn't match. Not an error, but we shouldn't remove the key.
69+
}
5470

5571
return HRESULT_FROM_WIN32(RegDeleteTree(HKEY_CLASSES_ROOT, currentSubKey.c_str()));
5672
}

0 commit comments

Comments
 (0)