[SHELL32] Fix improperly formatted or missing disk letter in disk Properties. By...
authorAmine Khaldi <amine.khaldi@reactos.org>
Wed, 22 Apr 2015 22:16:58 +0000 (22:16 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Wed, 22 Apr 2015 22:16:58 +0000 (22:16 +0000)
svn path=/trunk/; revision=67358

reactos/dll/win32/shell32/dialogs/drive.cpp

index f74fac7..491d8b4 100644 (file)
@@ -137,12 +137,27 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST
     {
         psh.pszCaption = wszName;
         psh.dwFlags |= PSH_PROPTITLE;
+        pwszDrive[2] = 0;
         if (wszName[0] == UNICODE_NULL)
         {
-            /* FIXME: check if disk is a really a local hdd */
-            UINT i = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, wszName, sizeof(wszName) / sizeof(WCHAR) - 6);
-            StringCchPrintf(wszName + i, sizeof(wszName) / sizeof(WCHAR) - i, L" (%s)", pwszDrive);
+            UINT len;
+            switch (GetDriveTypeW(pwszDrive))
+            {
+                case DRIVE_CDROM:
+                    len = LoadStringW(shell32_hInstance, IDS_DRIVE_CDROM, wszName, _countof(wszName));
+                    break;
+                case DRIVE_REMOTE:
+                    len = LoadStringW(shell32_hInstance, IDS_DRIVE_NETWORK, wszName, _countof(wszName));
+                    break;
+                case DRIVE_FIXED:
+                default:
+                    len = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, wszName, _countof(wszName));
+                    break;
+            }
+            StringCchPrintf(wszName + len, _countof(wszName) - len, L" (%s)", pwszDrive);
         }
+        else
+            StringCchPrintf(wszName + wcslen(wszName), _countof(wszName) - wcslen(wszName), L" (%s)", pwszDrive);
     }
 
     CComPtr<IDataObject> pDataObj;