From e60ec41e0671bb144e7c707f0dd7f0ce51b0193a Mon Sep 17 00:00:00 2001 From: Damjan Jovanovic Date: Mon, 19 Jan 2009 18:32:43 +0200 Subject: [PATCH] shlwapi: Support the friendly doc name and default icon queries. --- dlls/shlwapi/assoc.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/dlls/shlwapi/assoc.c b/dlls/shlwapi/assoc.c index 070ca1ab77a..53a873f92f5 100644 --- a/dlls/shlwapi/assoc.c +++ b/dlls/shlwapi/assoc.c @@ -772,6 +772,38 @@ static HRESULT WINAPI IQueryAssociations_fnGetString( return ASSOC_ReturnData(pszOut, pcchOut, path, len); } + case ASSOCSTR_FRIENDLYDOCNAME: + { + WCHAR *pszFileType; + DWORD ret; + DWORD size; + + hr = ASSOC_GetValue(This->hkeySource, &pszFileType); + if (FAILED(hr)) + return hr; + size = 0; + ret = RegGetValueW(HKEY_CLASSES_ROOT, pszFileType, NULL, RRF_RT_REG_SZ, NULL, NULL, &size); + if (ret == ERROR_SUCCESS) + { + WCHAR *docName = HeapAlloc(GetProcessHeap(), 0, size); + if (docName) + { + ret = RegGetValueW(HKEY_CLASSES_ROOT, pszFileType, NULL, RRF_RT_REG_SZ, NULL, docName, &size); + if (ret == ERROR_SUCCESS) + hr = ASSOC_ReturnData(pszOut, pcchOut, docName, strlenW(docName) + 1); + else + hr = HRESULT_FROM_WIN32(ret); + HeapFree(GetProcessHeap(), 0, docName); + } + else + hr = E_OUTOFMEMORY; + } + else + hr = HRESULT_FROM_WIN32(ret); + HeapFree(GetProcessHeap(), 0, pszFileType); + return hr; + } + case ASSOCSTR_FRIENDLYAPPNAME: { PVOID verinfoW = NULL; @@ -851,6 +883,47 @@ get_friendly_name_fail: return hr; } + case ASSOCSTR_DEFAULTICON: + { + static const WCHAR DefaultIconW[] = {'D','e','f','a','u','l','t','I','c','o','n',0}; + WCHAR *pszFileType; + DWORD ret; + DWORD size; + HKEY hkeyFile; + + hr = ASSOC_GetValue(This->hkeySource, &pszFileType); + if (FAILED(hr)) + return hr; + ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, pszFileType, 0, KEY_READ, &hkeyFile); + if (ret == ERROR_SUCCESS) + { + size = 0; + ret = RegGetValueW(hkeyFile, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, NULL, &size); + if (ret == ERROR_SUCCESS) + { + WCHAR *icon = HeapAlloc(GetProcessHeap(), 0, size); + if (icon) + { + ret = RegGetValueW(hkeyFile, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, icon, &size); + if (ret == ERROR_SUCCESS) + hr = ASSOC_ReturnData(pszOut, pcchOut, icon, strlenW(icon) + 1); + else + hr = HRESULT_FROM_WIN32(ret); + HeapFree(GetProcessHeap(), 0, icon); + } + else + hr = E_OUTOFMEMORY; + } + else + hr = HRESULT_FROM_WIN32(ret); + RegCloseKey(hkeyFile); + } + else + hr = HRESULT_FROM_WIN32(ret); + HeapFree(GetProcessHeap(), 0, pszFileType); + return hr; + } + default: FIXME("assocstr %d unimplemented!\n", str); return E_NOTIMPL; -- 2.11.4.GIT