Correctly handle flags parameter in SHAddToRecentDocs
Dmitry Timoshkov
dmitry at baikal.ru
Wed Oct 26 08:45:01 CDT 2005
Hello,
this patch fixes a crash in the app I'm working on. The app calls
SHAddToRecentDocs with uFlags set to 0x3 (SHARD_PATHW). MSDN states that
uFlags should be set to one of SHARD_PATHA, SHARD_PATHW or SHARD_PIDL.
Current code uses bitwise operations to detect the SHARD_PIDL case,
which leads to the problems with SHARD_PATHW.
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
Correctly handle flags parameter in SHAddToRecentDocs.
--- cvs/hq/wine/dlls/shell32/shellord.c 2005-09-05 19:44:51.000000000 +0900
+++ wine_hq_src/dlls/shell32/shellord.c 2005-10-26 22:36:50.000000000 +0900
@@ -623,11 +623,13 @@ static INT SHADD_create_add_mru_data(HAN
* 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 uFla
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 uFla
/* 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 uFla
}
/* 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);
More information about the wine-patches
mailing list