shell32: SHCreatePropSheetExtArrayEx should check if the key itself contains the clsid of the shell extension.

This commit is contained in:
David Hedberg 2010-03-16 01:32:45 +01:00 committed by Alexandre Julliard
parent 990a319750
commit 50c7cf5111
1 changed files with 26 additions and 20 deletions

View File

@ -1807,34 +1807,40 @@ HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_
break; break;
} }
dwClsidSize = sizeof(szClsidHandler); /* The CLSID is stored either in the key itself or in its default value. */
if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS) if (!SUCCEEDED(lRet = SHCLSIDFromStringW(szHandler, &clsid)))
{ {
/* Force a NULL-termination and convert the string */ dwClsidSize = sizeof(szClsidHandler);
szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0; if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler, &clsid)))
{ {
/* Attempt to get an IShellPropSheetExt and an IShellExtInit instance. /* Force a NULL-termination and convert the string */
Only if both interfaces are supported it's a real shell extension. szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
Then call IShellExtInit's Initialize method. */ lRet = SHCLSIDFromStringW(szClsidHandler, &clsid);
if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx))) }
}
if (SUCCEEDED(lRet))
{
/* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
Only if both interfaces are supported it's a real shell extension.
Then call IShellExtInit's Initialize method. */
if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
{
if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
{ {
if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi))) if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey)))
{ {
if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey))) /* Add the IShellPropSheetExt instance to the array */
{ psxa->pspsx[psxa->uiCount++] = pspsx;
/* Add the IShellPropSheetExt instance to the array */
psxa->pspsx[psxa->uiCount++] = pspsx;
}
else
{
psxi->lpVtbl->Release(psxi);
pspsx->lpVtbl->Release(pspsx);
}
} }
else else
{
psxi->lpVtbl->Release(psxi);
pspsx->lpVtbl->Release(pspsx); pspsx->lpVtbl->Release(pspsx);
}
} }
else
pspsx->lpVtbl->Release(pspsx);
} }
} }