ISF_MyComputer_fnParseDisplayName()

Martin Fuchs martin-fuchs at gmx.net
Wed Apr 14 13:47:55 CDT 2004


> Not all Unix locales map a..z to A..Z, so yes we have to use
> toupperW. But a better fix is probably to make _ILCreateDrive take a
> Unicode string and do the conversion in there.

OK, here is the new version.


Changelog:
- make drive letters in PIDLs always uppercase to enable PIDL comparison
- Unicodify _ILCreateDrive()


Index: pidl.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/pidl.c,v
retrieving revision 1.112
diff -u -p -d -r1.112 pidl.c
--- pidl.c	8 Apr 2004 04:37:43 -0000	1.112
+++ pidl.c	14 Apr 2004 18:46:36 -0000
@@ -1619,16 +1619,16 @@ LPITEMIDLIST _ILCreateFromPathA(LPCSTR s
 	return pidl;
 }
 
-LPITEMIDLIST _ILCreateDrive( LPCSTR lpszNew)
+LPITEMIDLIST _ILCreateDrive(LPCWSTR lpszNew)
 {
-    char sTemp[4];
+    WCHAR sTemp[4];
     LPITEMIDLIST pidlOut;
 
-    sTemp[0]=lpszNew[0];
+    sTemp[0]=toupperW(lpszNew[0]);
     sTemp[1]=':';
     sTemp[2]='\\';
     sTemp[3]=0x00;
-    TRACE("(%s)\n",sTemp);
+    TRACE("(%s)\n",debugstr_w(sTemp));
 
     /* FIXME: magic #s! */
     if ((pidlOut = _ILCreateWithTypeAndSize(PT_DRIVE, 25)))
@@ -1637,7 +1637,7 @@ LPITEMIDLIST _ILCreateDrive( LPCSTR lpsz
 
         if ((pszDest = _ILGetTextPointer(pidlOut)))
         {
-            memcpy(pszDest, sTemp, sizeof(sTemp));
+	    WideCharToMultiByte(CP_ACP, 0, sTemp, sizeof(sTemp)/sizeof(WCHAR), pszDest, sizeof(sTemp)/sizeof(WCHAR), NULL, NULL);
             TRACE("-- create Drive: %s\n", debugstr_a(pszDest));
         }
     }
Index: pidl.h
===================================================================
RCS file: /home/wine/wine/dlls/shell32/pidl.h,v
retrieving revision 1.39
diff -u -p -d -r1.39 pidl.h
--- pidl.h	8 Apr 2004 04:37:43 -0000	1.39
+++ pidl.h	14 Apr 2004 18:46:36 -0000
@@ -208,7 +208,7 @@ LPITEMIDLIST	_ILCreateControlPanel	(void
 LPITEMIDLIST	_ILCreatePrinters	(void);
 LPITEMIDLIST	_ILCreateNetwork	(void);
 LPITEMIDLIST	_ILCreateBitBucket	(void);
-LPITEMIDLIST	_ILCreateDrive		(LPCSTR);
+LPITEMIDLIST	_ILCreateDrive		(LPCWSTR);
 
 /*
  * helper functions (getting struct-pointer)
Index: shfldr_mycomp.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shfldr_mycomp.c,v
retrieving revision 1.20
diff -u -p -d -r1.20 shfldr_mycomp.c
--- shfldr_mycomp.c	13 Apr 2004 00:19:11 -0000	1.20
+++ shfldr_mycomp.c	14 Apr 2004 18:46:36 -0000
@@ -196,7 +196,6 @@ ISF_MyComputer_fnParseDisplayName (IShel
     HRESULT hr = E_INVALIDARG;
     LPCWSTR szNext = NULL;
     WCHAR szElement[MAX_PATH];
-    CHAR szTempA[MAX_PATH];
     LPITEMIDLIST pidlTemp = NULL;
     CLSID clsid;
 
@@ -217,8 +216,7 @@ ISF_MyComputer_fnParseDisplayName (IShel
     /* do we have an absolute path name ? */
     else if (PathGetDriveNumberW (lpszDisplayName) >= 0 && lpszDisplayName[2] == (WCHAR) '\\') {
 	szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
-	WideCharToMultiByte (CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL);
-	pidlTemp = _ILCreateDrive (szTempA);
+	pidlTemp = _ILCreateDrive (szElement);
     }
 
     if (szNext && *szNext) {
@@ -249,15 +247,15 @@ static BOOL CreateMyCompEnumList(IEnumID
     /*enumerate the folders*/
     if(dwFlags & SHCONTF_FOLDERS)
     {
-        CHAR szDriveName[] = "A:\\";
+        WCHAR wszDriveName[] = {'A', ':', '\\', '\0'};
         DWORD dwDrivemap = GetLogicalDrives();
         HKEY hkey;
 
-        while (ret && szDriveName[0]<='Z')
+        while (ret && wszDriveName[0]<='Z')
         {
             if(dwDrivemap & 0x00000001L)
-                ret = AddToEnumList(list, _ILCreateDrive(szDriveName));
-            szDriveName[0]++;
+                ret = AddToEnumList(list, _ILCreateDrive(wszDriveName));
+            wszDriveName[0]++;
             dwDrivemap = dwDrivemap >> 1;
         }
 






More information about the wine-patches mailing list