From 520bec000ffab93140653852207ab64b0fa0d0b1 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 27 Oct 2005 10:22:38 +0000 Subject: [PATCH] Correctly handle flags parameter in SHAddToRecentDocs. --- dlls/shell32/shellord.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c index 2fb50fa26ef..56d3301bcc7 100644 --- a/dlls/shell32/shellord.c +++ b/dlls/shell32/shellord.c @@ -623,11 +623,13 @@ static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPSTR doc_name, LPSTR new * SHAddToRecentDocs [SHELL32.@] * * PARAMETERS - * uFlags [IN] SHARD_PATH or SHARD_PIDL + * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL * pv [IN] string or pidl, NULL clears the list * * NOTES * exported by name + * + * FIXME: convert to unicode */ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv) { @@ -652,6 +654,8 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv) INT ret; DWORD data[64], datalen, type; + TRACE("%04x %p\n", uFlags, pv); + /*FIXME: Document: * RecentDocs MRU data structure seems to be: * +0h document file name w/ terminating 0h @@ -757,15 +761,28 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv) /* Get the pure document name from the input */ - if (uFlags & SHARD_PIDL) { + switch (uFlags) + { + case SHARD_PIDL: SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name); + break; + + case SHARD_PATHA: + lstrcpynA(doc_name, (LPCSTR)pv, MAX_PATH); + break; + + case SHARD_PATHW: + WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pv, -1, doc_name, MAX_PATH, NULL, NULL); + break; + + default: + FIXME("Unsupported flags: %u\n", uFlags); + return; } - else { - lstrcpyA(doc_name, (LPCSTR) pv); - } - TRACE("full document name %s\n", doc_name); + + TRACE("full document name %s\n", debugstr_a(doc_name)); PathStripPathA(doc_name); - TRACE("stripped document name %s\n", doc_name); + TRACE("stripped document name %s\n", debugstr_a(doc_name)); /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */ @@ -902,7 +919,7 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv) } /* Set the document path or pidl */ - if (uFlags & SHARD_PIDL) { + if (uFlags == SHARD_PIDL) { hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv); } else { hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);