Tools: Apply pre-commit autoformatting
This commit is contained in:
@@ -42,54 +42,52 @@ typedef struct _REGKEY_SUBKEY_AND_VALUE
|
||||
LPCWSTR lpszValue;
|
||||
DWORD dwType;
|
||||
DWORD_PTR dwData;
|
||||
;
|
||||
;
|
||||
} REGKEY_SUBKEY_AND_VALUE;
|
||||
|
||||
STDAPI CreateRegistryKeys(REGKEY_SUBKEY_AND_VALUE* aKeys, ULONG cKeys);
|
||||
STDAPI DeleteRegistryKeys(REGKEY_DELETEKEY* aKeys, ULONG cKeys);
|
||||
|
||||
|
||||
BOOL APIENTRY DllMain(HINSTANCE hinstDll,
|
||||
DWORD dwReason,
|
||||
LPVOID pvReserved)
|
||||
BOOL APIENTRY DllMain(HINSTANCE hinstDll, DWORD dwReason, LPVOID pvReserved)
|
||||
{
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
g_hinstDll = hinstDll;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
switch (dwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
g_hinstDll = hinstDll;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI_(HINSTANCE) DllInstance()
|
||||
{
|
||||
return g_hinstDll;
|
||||
return g_hinstDll;
|
||||
}
|
||||
|
||||
STDAPI DllCanUnloadNow()
|
||||
{
|
||||
return g_cRef ? S_FALSE : S_OK;
|
||||
return g_cRef ? S_FALSE : S_OK;
|
||||
}
|
||||
|
||||
STDAPI_(ULONG) DllAddRef()
|
||||
{
|
||||
LONG cRef = InterlockedIncrement(&g_cRef);
|
||||
return cRef;
|
||||
LONG cRef = InterlockedIncrement(&g_cRef);
|
||||
return cRef;
|
||||
}
|
||||
|
||||
STDAPI_(ULONG) DllRelease()
|
||||
{
|
||||
LONG cRef = InterlockedDecrement(&g_cRef);
|
||||
if (0 > cRef)
|
||||
cRef = 0;
|
||||
return cRef;
|
||||
LONG cRef = InterlockedDecrement(&g_cRef);
|
||||
if (0 > cRef)
|
||||
cRef = 0;
|
||||
return cRef;
|
||||
}
|
||||
|
||||
STDAPI DllRegisterServer()
|
||||
{
|
||||
// This tells the shell to invalidate the thumbnail cache. This is important because any .recipe files
|
||||
// viewed before registering this handler would otherwise show cached blank thumbnails.
|
||||
// This tells the shell to invalidate the thumbnail cache. This is important because any
|
||||
// .recipe files viewed before registering this handler would otherwise show cached blank
|
||||
// thumbnails.
|
||||
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
|
||||
|
||||
WCHAR szModule[MAX_PATH];
|
||||
@@ -97,19 +95,44 @@ STDAPI DllRegisterServer()
|
||||
ZeroMemory(szModule, sizeof(szModule));
|
||||
GetModuleFileName(g_hinstDll, szModule, ARRAYSIZE(szModule));
|
||||
|
||||
//uncomment the following
|
||||
// uncomment the following
|
||||
REGKEY_SUBKEY_AND_VALUE keys[] = {
|
||||
{HKEY_CLASSES_ROOT, L"CLSID\\" szCLSID_SampleThumbnailProvider, NULL, REG_SZ, (DWORD_PTR)L"FCStd Thumbnail Provider"},
|
||||
{HKEY_CLASSES_ROOT,
|
||||
L"CLSID\\" szCLSID_SampleThumbnailProvider,
|
||||
NULL,
|
||||
REG_SZ,
|
||||
(DWORD_PTR)L"FCStd Thumbnail Provider"},
|
||||
#if 1
|
||||
//{HKEY_CLASSES_ROOT, L"CLSID\\DisableProcessIsolation", NULL, REG_DWORD, (DWORD) 1},
|
||||
{HKEY_CLASSES_ROOT, L"CLSID\\" szCLSID_SampleThumbnailProvider, L"DisableProcessIsolation", REG_DWORD, (DWORD) 1},
|
||||
//{HKEY_CLASSES_ROOT, L"CLSID\\DisableProcessIsolation", NULL, REG_DWORD, (DWORD) 1},
|
||||
{HKEY_CLASSES_ROOT,
|
||||
L"CLSID\\" szCLSID_SampleThumbnailProvider,
|
||||
L"DisableProcessIsolation",
|
||||
REG_DWORD,
|
||||
(DWORD)1},
|
||||
#endif
|
||||
{HKEY_CLASSES_ROOT, L"CLSID\\" szCLSID_SampleThumbnailProvider L"\\InprocServer32", NULL, REG_SZ, (DWORD_PTR)szModule},
|
||||
{HKEY_CLASSES_ROOT, L"CLSID\\" szCLSID_SampleThumbnailProvider L"\\InprocServer32", L"ThreadingModel", REG_SZ, (DWORD_PTR)L"Apartment"},
|
||||
//{HKEY_CLASSES_ROOT, L".FCStd\\shellex", L"Trick only here to create shellex when not existing",REG_DWORD, 1},
|
||||
{HKEY_CLASSES_ROOT, L".FCStd\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}", NULL, REG_SZ, (DWORD_PTR)szCLSID_SampleThumbnailProvider},
|
||||
{HKEY_CLASSES_ROOT, L".FCBak\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}", NULL, REG_SZ, (DWORD_PTR)szCLSID_SampleThumbnailProvider}
|
||||
};
|
||||
{HKEY_CLASSES_ROOT,
|
||||
L"CLSID\\" szCLSID_SampleThumbnailProvider L"\\InprocServer32",
|
||||
NULL,
|
||||
REG_SZ,
|
||||
(DWORD_PTR)szModule},
|
||||
{HKEY_CLASSES_ROOT,
|
||||
L"CLSID\\" szCLSID_SampleThumbnailProvider L"\\InprocServer32",
|
||||
L"ThreadingModel",
|
||||
REG_SZ,
|
||||
(DWORD_PTR)L"Apartment"},
|
||||
//{HKEY_CLASSES_ROOT, L".FCStd\\shellex", L"Trick only here to create shellex when not
|
||||
// existing",REG_DWORD, 1},
|
||||
{HKEY_CLASSES_ROOT,
|
||||
L".FCStd\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}",
|
||||
NULL,
|
||||
REG_SZ,
|
||||
(DWORD_PTR)szCLSID_SampleThumbnailProvider},
|
||||
{HKEY_CLASSES_ROOT,
|
||||
L".FCBak\\shellex\\{E357FCCD-A995-4576-B01F-234630154E96}",
|
||||
NULL,
|
||||
REG_SZ,
|
||||
(DWORD_PTR)szCLSID_SampleThumbnailProvider}
|
||||
};
|
||||
|
||||
return CreateRegistryKeys(keys, ARRAYSIZE(keys));
|
||||
}
|
||||
@@ -127,32 +150,29 @@ STDAPI CreateRegistryKey(REGKEY_SUBKEY_AND_VALUE* pKey)
|
||||
LPVOID pvData = NULL;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
switch(pKey->dwType)
|
||||
{
|
||||
case REG_DWORD:
|
||||
pvData = (LPVOID)(LPDWORD)&pKey->dwData;
|
||||
cbData = sizeof(DWORD);
|
||||
break;
|
||||
switch (pKey->dwType) {
|
||||
case REG_DWORD:
|
||||
pvData = (LPVOID)(LPDWORD)&pKey->dwData;
|
||||
cbData = sizeof(DWORD);
|
||||
break;
|
||||
|
||||
case REG_SZ:
|
||||
case REG_EXPAND_SZ:
|
||||
hr = StringCbLength((LPCWSTR)pKey->dwData, STRSAFE_MAX_CCH, &cbData);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
pvData = (LPVOID)(LPCWSTR)pKey->dwData;
|
||||
cbData += sizeof(WCHAR);
|
||||
}
|
||||
break;
|
||||
case REG_SZ:
|
||||
case REG_EXPAND_SZ:
|
||||
hr = StringCbLength((LPCWSTR)pKey->dwData, STRSAFE_MAX_CCH, &cbData);
|
||||
if (SUCCEEDED(hr)) {
|
||||
pvData = (LPVOID)(LPCWSTR)pKey->dwData;
|
||||
cbData += sizeof(WCHAR);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
hr = E_INVALIDARG;
|
||||
default:
|
||||
hr = E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
LSTATUS status = SHSetValue(pKey->hKey, pKey->lpszSubKey, pKey->lpszValue, pKey->dwType, pvData, (DWORD)cbData);
|
||||
if (NOERROR != status)
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
LSTATUS status = SHSetValue(
|
||||
pKey->hKey, pKey->lpszSubKey, pKey->lpszValue, pKey->dwType, pvData, (DWORD)cbData);
|
||||
if (NOERROR != status) {
|
||||
hr = HRESULT_FROM_WIN32(status);
|
||||
}
|
||||
}
|
||||
@@ -161,16 +181,13 @@ STDAPI CreateRegistryKey(REGKEY_SUBKEY_AND_VALUE* pKey)
|
||||
}
|
||||
|
||||
|
||||
|
||||
STDAPI CreateRegistryKeys(REGKEY_SUBKEY_AND_VALUE* aKeys, ULONG cKeys)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
for (ULONG iKey = 0; iKey < cKeys; iKey++)
|
||||
{
|
||||
for (ULONG iKey = 0; iKey < cKeys; iKey++) {
|
||||
HRESULT hrTemp = CreateRegistryKey(&aKeys[iKey]);
|
||||
if (FAILED(hrTemp))
|
||||
{
|
||||
if (FAILED(hrTemp)) {
|
||||
hr = hrTemp;
|
||||
}
|
||||
}
|
||||
@@ -183,13 +200,11 @@ STDAPI DeleteRegistryKeys(REGKEY_DELETEKEY* aKeys, ULONG cKeys)
|
||||
HRESULT hr = S_OK;
|
||||
LSTATUS status;
|
||||
|
||||
for (ULONG iKey = 0; iKey < cKeys; iKey++)
|
||||
{
|
||||
for (ULONG iKey = 0; iKey < cKeys; iKey++) {
|
||||
status = RegDeleteTree(aKeys[iKey].hKey, aKeys[iKey].lpszSubKey);
|
||||
if (NOERROR != status)
|
||||
{
|
||||
if (NOERROR != status) {
|
||||
hr = HRESULT_FROM_WIN32(status);
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user