mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:42:58 +00:00
[SHELL32] sync CQueryAssociations.cpp with wine
svn path=/trunk/; revision=72578
This commit is contained in:
parent
7028633b58
commit
e3b66d324c
1 changed files with 56 additions and 41 deletions
|
@ -96,6 +96,9 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::Init(
|
||||||
this->hkeySource = this->hkeyProgID = NULL;
|
this->hkeySource = this->hkeyProgID = NULL;
|
||||||
if (pszAssoc != NULL)
|
if (pszAssoc != NULL)
|
||||||
{
|
{
|
||||||
|
WCHAR *progId;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
LONG ret = RegOpenKeyExW(HKEY_CLASSES_ROOT,
|
LONG ret = RegOpenKeyExW(HKEY_CLASSES_ROOT,
|
||||||
pszAssoc,
|
pszAssoc,
|
||||||
0,
|
0,
|
||||||
|
@ -105,29 +108,58 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::Init(
|
||||||
{
|
{
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
/* if this is not a prog id */
|
|
||||||
if ((*pszAssoc == '.') || (*pszAssoc == '{'))
|
/* if this is a progid */
|
||||||
{
|
if (*pszAssoc != '.' && *pszAssoc != '{')
|
||||||
RegOpenKeyExW(this->hkeySource,
|
|
||||||
szProgID,
|
|
||||||
0,
|
|
||||||
KEY_READ,
|
|
||||||
&this->hkeyProgID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this->hkeyProgID = this->hkeySource;
|
this->hkeyProgID = this->hkeySource;
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if it's not a progid, it's a file extension or clsid */
|
||||||
|
if (*pszAssoc == '.')
|
||||||
|
{
|
||||||
|
/* for a file extension, the progid is the default value */
|
||||||
|
hr = this->GetValue(this->hkeySource, NULL, (void**)&progId, NULL);
|
||||||
|
if (FAILED(hr))
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
else /* if (*pszAssoc == '{') */
|
||||||
|
{
|
||||||
|
HKEY progIdKey;
|
||||||
|
/* for a clsid, the progid is the default value of the ProgID subkey */
|
||||||
|
ret = RegOpenKeyExW(this->hkeySource,
|
||||||
|
szProgID,
|
||||||
|
0,
|
||||||
|
KEY_READ,
|
||||||
|
&progIdKey);
|
||||||
|
if (ret != ERROR_SUCCESS)
|
||||||
|
return S_OK;
|
||||||
|
hr = this->GetValue(progIdKey, NULL, (void**)&progId, NULL);
|
||||||
|
if (FAILED(hr))
|
||||||
|
return S_OK;
|
||||||
|
RegCloseKey(progIdKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* open the actual progid key, the one with the shell subkey */
|
||||||
|
ret = RegOpenKeyExW(HKEY_CLASSES_ROOT,
|
||||||
|
progId,
|
||||||
|
0,
|
||||||
|
KEY_READ,
|
||||||
|
&this->hkeyProgID);
|
||||||
|
HeapFree(GetProcessHeap(), 0, progId);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
else if (hkeyProgid != NULL)
|
else if (hkeyProgid != NULL)
|
||||||
{
|
{
|
||||||
this->hkeyProgID = hkeyProgid;
|
/* reopen the key so we don't end up closing a key owned by the caller */
|
||||||
|
RegOpenKeyExW(hkeyProgid, NULL, 0, KEY_READ, &this->hkeyProgID);
|
||||||
|
this->hkeySource = this->hkeyProgID;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -324,51 +356,34 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString(
|
||||||
case ASSOCSTR_DEFAULTICON:
|
case ASSOCSTR_DEFAULTICON:
|
||||||
{
|
{
|
||||||
static const WCHAR DefaultIconW[] = L"DefaultIcon";
|
static const WCHAR DefaultIconW[] = L"DefaultIcon";
|
||||||
WCHAR *pszFileType;
|
DWORD ret;
|
||||||
HKEY hkeyFile;
|
DWORD size = 0;
|
||||||
|
ret = RegGetValueW(this->hkeyProgID, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
|
||||||
hr = this->GetValue(this->hkeySource, NULL, (void**)&pszFileType, NULL);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
DWORD ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, pszFileType, 0, KEY_READ, &hkeyFile);
|
|
||||||
if (ret == ERROR_SUCCESS)
|
if (ret == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DWORD size = 0;
|
WCHAR *icon = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
|
||||||
ret = RegGetValueW(hkeyFile, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
|
if (icon)
|
||||||
if (ret == ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
WCHAR *icon = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
|
ret = RegGetValueW(this->hkeyProgID, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, icon, &size);
|
||||||
if (icon)
|
if (ret == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ret = RegGetValueW(hkeyFile, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, icon, &size);
|
hr = this->ReturnString(flags, pszOut, pcchOut, icon, strlenW(icon) + 1);
|
||||||
if (ret == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
hr = this->ReturnString(flags, pszOut, pcchOut, icon, strlenW(icon) + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hr = HRESULT_FROM_WIN32(ret);
|
|
||||||
}
|
|
||||||
HeapFree(GetProcessHeap(), 0, icon);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hr = E_OUTOFMEMORY;
|
hr = HRESULT_FROM_WIN32(ret);
|
||||||
}
|
}
|
||||||
|
HeapFree(GetProcessHeap(), 0, icon);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hr = HRESULT_FROM_WIN32(ret);
|
hr = HRESULT_FROM_WIN32(ret);
|
||||||
}
|
}
|
||||||
RegCloseKey(hkeyFile);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hr = HRESULT_FROM_WIN32(ret);
|
hr = HRESULT_FROM_WIN32(ret);
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, pszFileType);
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
case ASSOCSTR_SHELLEXTENSION:
|
case ASSOCSTR_SHELLEXTENSION:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue