shell32: Avoid W->A conversion in RenderHDROP.

This commit is contained in:
Ken Thomases 2007-03-14 13:17:29 -05:00 committed by Alexandre Julliard
parent 5faa3d0a59
commit 8f5f3f5b8e

View file

@ -60,9 +60,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
{ {
UINT i; UINT i;
int rootsize = 0,size = 0; int rootlen = 0,size = 0;
char szRootPath[MAX_PATH]; WCHAR wszRootPath[MAX_PATH];
char szFileName[MAX_PATH]; WCHAR wszFileName[MAX_PATH];
HGLOBAL hGlobal; HGLOBAL hGlobal;
DROPFILES *pDropFiles; DROPFILES *pDropFiles;
int offset; int offset;
@ -72,39 +72,38 @@ HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
/* get the size needed */ /* get the size needed */
size = sizeof(DROPFILES); size = sizeof(DROPFILES);
SHGetPathFromIDListA(pidlRoot, szRootPath); SHGetPathFromIDListW(pidlRoot, wszRootPath);
PathAddBackslashA(szRootPath); PathAddBackslashW(wszRootPath);
rootsize = strlen(szRootPath); rootlen = strlenW(wszRootPath);
for (i=0; i<cidl;i++) for (i=0; i<cidl;i++)
{ {
_ILSimpleGetText(apidl[i], szFileName, MAX_PATH); _ILSimpleGetTextW(apidl[i], wszFileName, MAX_PATH);
size += rootsize + strlen(szFileName) + 1; size += (rootlen + strlenW(wszFileName) + 1) * sizeof(WCHAR);
} }
size++; size += sizeof(WCHAR);
/* Fill the structure */ /* Fill the structure */
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
if(!hGlobal) return hGlobal; if(!hGlobal) return hGlobal;
pDropFiles = (DROPFILES *)GlobalLock(hGlobal); pDropFiles = (DROPFILES *)GlobalLock(hGlobal);
pDropFiles->pFiles = sizeof(DROPFILES); offset = (sizeof(DROPFILES) + sizeof(WCHAR) - 1) / sizeof(WCHAR);
pDropFiles->fWide = FALSE; pDropFiles->pFiles = offset * sizeof(WCHAR);
pDropFiles->fWide = TRUE;
offset = pDropFiles->pFiles; strcpyW(wszFileName, wszRootPath);
strcpy(szFileName, szRootPath);
for (i=0; i<cidl;i++) for (i=0; i<cidl;i++)
{ {
_ILSimpleGetText(apidl[i], szFileName + rootsize, MAX_PATH - rootsize); _ILSimpleGetTextW(apidl[i], wszFileName + rootlen, MAX_PATH - rootlen);
size = strlen(szFileName) + 1; strcpyW(((WCHAR*)pDropFiles)+offset, wszFileName);
strcpy(((char*)pDropFiles)+offset, szFileName); offset += strlenW(wszFileName) + 1;
offset += size;
} }
((char*)pDropFiles)[offset] = 0; ((WCHAR*)pDropFiles)[offset] = 0;
GlobalUnlock(hGlobal); GlobalUnlock(hGlobal);
return hGlobal; return hGlobal;