Lei Zhang : shlwapi: Handle ASSOCSTR_FRIENDLYAPPNAME in IQueryAssociations_GetString.
Alexandre Julliard
julliard at winehq.org
Tue Oct 14 08:30:19 CDT 2008
Module: wine
Branch: master
Commit: 57122e4daa7fe7027d7975083057d87f052e2650
URL: http://source.winehq.org/git/wine.git/?a=commit;h=57122e4daa7fe7027d7975083057d87f052e2650
Author: Lei Zhang <thestig at google.com>
Date: Mon Oct 13 18:15:54 2008 -0700
shlwapi: Handle ASSOCSTR_FRIENDLYAPPNAME in IQueryAssociations_GetString.
---
dlls/shlwapi/assoc.c | 54 ++++++++++++++++++++++++++++++++++++++++++++
dlls/shlwapi/tests/assoc.c | 4 +-
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/dlls/shlwapi/assoc.c b/dlls/shlwapi/assoc.c
index 882b881..7f71708 100644
--- a/dlls/shlwapi/assoc.c
+++ b/dlls/shlwapi/assoc.c
@@ -27,6 +27,7 @@
#include "objbase.h"
#include "shlguid.h"
#include "shlwapi.h"
+#include "ver.h"
#include "wine/unicode.h"
#include "wine/debug.h"
@@ -745,6 +746,59 @@ static HRESULT WINAPI IQueryAssociations_fnGetString(
break;
}
+ case ASSOCSTR_FRIENDLYAPPNAME:
+ {
+ PVOID verinfoW = NULL;
+ DWORD size, retval = 0;
+ UINT flen;
+ WCHAR *bufW;
+ static const WCHAR translationW[] = {
+ '\\','V','a','r','F','i','l','e','I','n','f','o',
+ '\\','T','r','a','n','s','l','a','t','i','o','n',0
+ };
+ static const WCHAR fileDescFmtW[] = {
+ '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
+ '\\','%','0','4','x','%','0','4','x',
+ '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0
+ };
+ WCHAR fileDescW[41];
+
+ hr = ASSOC_GetExecutable(This, pszExtra, path, MAX_PATH, &len);
+ if (FAILED(hr))
+ return hr;
+
+ retval = GetFileVersionInfoSizeW(path, &size);
+ if (!retval)
+ goto get_friendly_name_fail;
+ verinfoW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
+ if (!verinfoW)
+ return E_OUTOFMEMORY;
+ if (!GetFileVersionInfoW(path, 0, retval, verinfoW))
+ goto get_friendly_name_fail;
+ if (VerQueryValueW(verinfoW, translationW, (LPVOID *)&bufW, &flen))
+ {
+ int i;
+ DWORD *langCodeDesc = (DWORD *)bufW;
+ for (i = 0; i < flen / sizeof(DWORD); i++)
+ {
+ sprintfW(fileDescW, fileDescFmtW, LOWORD(langCodeDesc[i]),
+ HIWORD(langCodeDesc[i]));
+ if (VerQueryValueW(verinfoW, fileDescW, (LPVOID *)&bufW, &flen))
+ {
+ /* Does strlenW(bufW) == 0 mean we use the filename? */
+ len = strlenW(bufW) + 1;
+ TRACE("found FileDescription: %s\n", debugstr_w(bufW));
+ return ASSOC_ReturnData(pszOut, pcchOut, bufW, len);
+ }
+ }
+ }
+get_friendly_name_fail:
+ PathRemoveExtensionW(path);
+ PathStripPathW(path);
+ TRACE("using filename: %s\n", debugstr_w(path));
+ return ASSOC_ReturnData(pszOut, pcchOut, path, strlenW(path) + 1);
+ }
+
default:
FIXME("assocstr %d unimplemented!\n", str);
return E_NOTIMPL;
diff --git a/dlls/shlwapi/tests/assoc.c b/dlls/shlwapi/tests/assoc.c
index bb1c4d6..e5d40d1 100644
--- a/dlls/shlwapi/tests/assoc.c
+++ b/dlls/shlwapi/tests/assoc.c
@@ -59,7 +59,7 @@ static void test_getstring_bad(void)
expect_hr(E_FAIL, hr);
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, invalid, NULL,
&len);
- todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
+ expect_hr(0x80070002, hr); /* NOT FOUND */
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
NULL);
expect_hr(E_UNEXPECTED, hr);
@@ -98,7 +98,7 @@ static void test_getstring_basic(void)
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
&len);
- todo_wine expect_hr(S_FALSE, hr);
+ expect_hr(S_FALSE, hr);
if (hr != S_FALSE)
{
HeapFree(GetProcessHeap(), 0, executableName);
More information about the wine-cvs
mailing list