2012-01-11 21:58:47 +00:00
|
|
|
/*
|
|
|
|
* Provides default drive shell extension
|
|
|
|
*
|
|
|
|
* Copyright 2005 Johannes Anderwald
|
|
|
|
* Copyright 2012 Rafal Harabien
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2012-01-11 20:20:01 +00:00
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2014-01-25 17:24:24 +00:00
|
|
|
|
|
|
|
#define _USE_MATH_DEFINES
|
2012-01-12 20:10:35 +00:00
|
|
|
#include <math.h>
|
2012-01-11 21:58:47 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
static const GUID GUID_DEVCLASS_DISKDRIVE = {0x4d36e967L, 0xe325, 0x11ce, {0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18}};
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
HWPD_STANDARDLIST = 0,
|
|
|
|
HWPD_LARGELIST,
|
|
|
|
HWPD_MAX = HWPD_LARGELIST
|
|
|
|
} HWPAGE_DISPLAYMODE, *PHWPAGE_DISPLAYMODE;
|
|
|
|
|
|
|
|
EXTERN_C HWND WINAPI
|
|
|
|
DeviceCreateHardwarePageEx(HWND hWndParent,
|
|
|
|
LPGUID lpGuids,
|
|
|
|
UINT uNumberOfGuids,
|
|
|
|
HWPAGE_DISPLAYMODE DisplayMode);
|
2012-01-13 17:42:27 +00:00
|
|
|
UINT SH_FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax);
|
2012-01-11 21:58:47 +00:00
|
|
|
|
|
|
|
static VOID
|
|
|
|
GetDriveNameWithLetter(LPWSTR pwszText, UINT cchTextMax, LPCWSTR pwszDrive)
|
|
|
|
{
|
2012-02-08 21:38:53 +00:00
|
|
|
DWORD dwMaxComp, dwFileSys;
|
|
|
|
SIZE_T cchText = 0;
|
2012-01-11 21:58:47 +00:00
|
|
|
|
|
|
|
if (GetVolumeInformationW(pwszDrive, pwszText, cchTextMax, NULL, &dwMaxComp, &dwFileSys, NULL, 0))
|
|
|
|
{
|
|
|
|
cchText = wcslen(pwszText);
|
|
|
|
if (cchText == 0)
|
|
|
|
{
|
|
|
|
/* load default volume label */
|
|
|
|
cchText = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, pwszText, cchTextMax);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-22 07:23:49 +00:00
|
|
|
StringCchPrintfW(pwszText + cchText, cchTextMax - cchText, L" (%c:)", pwszDrive[0]);
|
2012-01-11 21:58:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
InitializeChkDskDialog(HWND hwndDlg, LPCWSTR pwszDrive)
|
|
|
|
{
|
|
|
|
WCHAR wszText[100];
|
|
|
|
UINT Length;
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pwszDrive);
|
|
|
|
|
|
|
|
Length = GetWindowTextW(hwndDlg, wszText, sizeof(wszText) / sizeof(WCHAR));
|
|
|
|
wszText[Length] = L' ';
|
|
|
|
GetDriveNameWithLetter(&wszText[Length + 1], (sizeof(wszText) / sizeof(WCHAR)) - Length - 1, pwszDrive);
|
|
|
|
SetWindowText(hwndDlg, wszText);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND hChkdskDrvDialog = NULL;
|
|
|
|
static BOOLEAN bChkdskSuccess = FALSE;
|
|
|
|
|
|
|
|
static BOOLEAN NTAPI
|
|
|
|
ChkdskCallback(
|
|
|
|
IN CALLBACKCOMMAND Command,
|
|
|
|
IN ULONG SubAction,
|
|
|
|
IN PVOID ActionInfo)
|
|
|
|
{
|
|
|
|
PDWORD Progress;
|
|
|
|
PBOOLEAN pSuccess;
|
|
|
|
switch(Command)
|
|
|
|
{
|
|
|
|
case PROGRESS:
|
|
|
|
Progress = (PDWORD)ActionInfo;
|
|
|
|
SendDlgItemMessageW(hChkdskDrvDialog, 14002, PBM_SETPOS, (WPARAM)*Progress, 0);
|
|
|
|
break;
|
|
|
|
case DONE:
|
|
|
|
pSuccess = (PBOOLEAN)ActionInfo;
|
|
|
|
bChkdskSuccess = (*pSuccess);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VOLUMEINUSE:
|
|
|
|
case INSUFFICIENTRIGHTS:
|
|
|
|
case FSNOTSUPPORTED:
|
|
|
|
case CLUSTERSIZETOOSMALL:
|
|
|
|
bChkdskSuccess = FALSE;
|
|
|
|
FIXME("\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
ChkDskNow(HWND hwndDlg, LPCWSTR pwszDrive)
|
|
|
|
{
|
|
|
|
//DWORD ClusterSize = 0;
|
|
|
|
WCHAR wszFs[30];
|
|
|
|
ULARGE_INTEGER TotalNumberOfFreeBytes, FreeBytesAvailableUser;
|
|
|
|
BOOLEAN bCorrectErrors = FALSE, bScanDrive = FALSE;
|
|
|
|
|
|
|
|
if(!GetVolumeInformationW(pwszDrive, NULL, 0, NULL, NULL, NULL, wszFs, _countof(wszFs)))
|
|
|
|
{
|
|
|
|
FIXME("failed to get drive fs type\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GetDiskFreeSpaceExW(pwszDrive, &FreeBytesAvailableUser, &TotalNumberOfFreeBytes, NULL))
|
|
|
|
{
|
|
|
|
FIXME("failed to get drive space type\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*if (!GetDefaultClusterSize(wszFs, &ClusterSize, &TotalNumberOfFreeBytes))
|
|
|
|
{
|
|
|
|
FIXME("invalid cluster size\n");
|
|
|
|
return;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
if (SendDlgItemMessageW(hwndDlg, 14000, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
|
|
|
bCorrectErrors = TRUE;
|
|
|
|
|
|
|
|
if (SendDlgItemMessageW(hwndDlg, 14001, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
|
|
|
bScanDrive = TRUE;
|
|
|
|
|
|
|
|
hChkdskDrvDialog = hwndDlg;
|
|
|
|
bChkdskSuccess = FALSE;
|
|
|
|
SendDlgItemMessageW(hwndDlg, 14002, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
|
|
|
|
Chkdsk((LPWSTR)pwszDrive, (LPWSTR)wszFs, bCorrectErrors, TRUE, FALSE, bScanDrive, NULL, NULL, ChkdskCallback); // FIXME: casts
|
|
|
|
|
|
|
|
hChkdskDrvDialog = NULL;
|
|
|
|
bChkdskSuccess = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK
|
|
|
|
ChkDskDlg(
|
|
|
|
HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam);
|
|
|
|
InitializeChkDskDialog(hwndDlg, (LPCWSTR)lParam);
|
|
|
|
return TRUE;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch(LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hwndDlg, 0);
|
|
|
|
break;
|
|
|
|
case IDOK:
|
|
|
|
{
|
|
|
|
LPCWSTR pwszDrive = (LPCWSTR)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
ChkDskNow(hwndDlg, pwszDrive);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CDrvDefExt::PaintStaticControls(HWND hwndDlg, LPDRAWITEMSTRUCT pDrawItem)
|
|
|
|
{
|
|
|
|
HBRUSH hBrush;
|
|
|
|
|
|
|
|
if (pDrawItem->CtlID == 14013)
|
|
|
|
{
|
|
|
|
hBrush = CreateSolidBrush(RGB(0, 0, 255));
|
|
|
|
if (hBrush)
|
|
|
|
{
|
|
|
|
FillRect(pDrawItem->hDC, &pDrawItem->rcItem, hBrush);
|
|
|
|
DeleteObject((HGDIOBJ)hBrush);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pDrawItem->CtlID == 14014)
|
|
|
|
{
|
|
|
|
hBrush = CreateSolidBrush(RGB(255, 0, 255));
|
|
|
|
if (hBrush)
|
|
|
|
{
|
|
|
|
FillRect(pDrawItem->hDC, &pDrawItem->rcItem, hBrush);
|
|
|
|
DeleteObject((HGDIOBJ)hBrush);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pDrawItem->CtlID == 14015)
|
|
|
|
{
|
2012-01-12 20:10:35 +00:00
|
|
|
HBRUSH hBlueBrush = CreateSolidBrush(RGB(0, 0, 255));
|
|
|
|
HBRUSH hMagBrush = CreateSolidBrush(RGB(255, 0, 255));
|
2017-09-08 20:00:59 +00:00
|
|
|
HBRUSH hbrOld;
|
2012-01-12 20:10:35 +00:00
|
|
|
HPEN hDarkBluePen = CreatePen(PS_SOLID, 1, RGB(0, 0, 128));
|
|
|
|
HPEN hDarkMagPen = CreatePen(PS_SOLID, 1, RGB(128, 0, 128));
|
2017-09-08 20:00:59 +00:00
|
|
|
HPEN hOldPen = (HPEN)SelectObject(pDrawItem->hDC, hDarkMagPen);
|
|
|
|
INT xCenter = (pDrawItem->rcItem.left + pDrawItem->rcItem.right) / 2;
|
|
|
|
INT yCenter = (pDrawItem->rcItem.top + pDrawItem->rcItem.bottom - 10) / 2;
|
2012-01-12 20:10:35 +00:00
|
|
|
INT cx = pDrawItem->rcItem.right - pDrawItem->rcItem.left;
|
|
|
|
INT cy = pDrawItem->rcItem.bottom - pDrawItem->rcItem.top - 10;
|
2017-09-08 20:00:59 +00:00
|
|
|
INT xRadial = xCenter + (INT)(cos(M_PI + m_FreeSpacePerc / 100.0f * M_PI * 2.0f) * cx / 2);
|
|
|
|
INT yRadial = yCenter - (INT)(sin(M_PI + m_FreeSpacePerc / 100.0f * M_PI * 2.0f) * cy / 2);
|
2012-01-12 20:10:35 +00:00
|
|
|
|
2017-09-08 20:00:59 +00:00
|
|
|
TRACE("FreeSpace %u a %f cx %d\n", m_FreeSpacePerc, M_PI+m_FreeSpacePerc / 100.0f * M_PI * 2.0f, cx);
|
2015-04-22 22:24:46 +00:00
|
|
|
|
2012-01-12 20:10:35 +00:00
|
|
|
for (INT x = pDrawItem->rcItem.left; x < pDrawItem->rcItem.right; ++x)
|
|
|
|
{
|
2017-09-08 20:00:59 +00:00
|
|
|
double cos_val = (x - xCenter) * 2.0f / cx;
|
|
|
|
INT y = yCenter + (INT)(sin(acos(cos_val)) * cy / 2) - 1;
|
|
|
|
|
2012-01-13 17:42:27 +00:00
|
|
|
if (m_FreeSpacePerc < 50 && x == xRadial)
|
2012-12-28 17:42:50 +00:00
|
|
|
SelectObject(pDrawItem->hDC, hDarkBluePen);
|
2012-01-12 20:10:35 +00:00
|
|
|
|
|
|
|
MoveToEx(pDrawItem->hDC, x, y, NULL);
|
|
|
|
LineTo(pDrawItem->hDC, x, y + 10);
|
|
|
|
}
|
2017-09-08 20:00:59 +00:00
|
|
|
|
2012-01-12 20:10:35 +00:00
|
|
|
SelectObject(pDrawItem->hDC, hOldPen);
|
|
|
|
|
2017-09-08 20:00:59 +00:00
|
|
|
if (m_FreeSpacePerc > 50)
|
|
|
|
{
|
|
|
|
hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hMagBrush);
|
|
|
|
|
|
|
|
Ellipse(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top,
|
|
|
|
pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10);
|
|
|
|
|
|
|
|
SelectObject(pDrawItem->hDC, hBlueBrush);
|
|
|
|
|
|
|
|
if (m_FreeSpacePerc < 100)
|
|
|
|
{
|
|
|
|
Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right,
|
|
|
|
pDrawItem->rcItem.bottom - 10, xRadial, yRadial, pDrawItem->rcItem.left, yCenter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hBlueBrush);
|
|
|
|
|
|
|
|
Ellipse(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top,
|
|
|
|
pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10);
|
|
|
|
|
|
|
|
SelectObject(pDrawItem->hDC, hMagBrush);
|
|
|
|
|
|
|
|
if (m_FreeSpacePerc > 0)
|
|
|
|
{
|
|
|
|
Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right,
|
|
|
|
pDrawItem->rcItem.bottom - 10, pDrawItem->rcItem.left, yCenter, xRadial, yRadial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectObject(pDrawItem->hDC, hbrOld);
|
|
|
|
|
2012-01-11 21:58:47 +00:00
|
|
|
DeleteObject(hBlueBrush);
|
|
|
|
DeleteObject(hMagBrush);
|
2012-01-12 20:10:35 +00:00
|
|
|
DeleteObject(hDarkBluePen);
|
|
|
|
DeleteObject(hDarkMagPen);
|
2012-01-11 21:58:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CDrvDefExt::InitGeneralPage(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
WCHAR wszVolumeName[MAX_PATH+1] = {0};
|
|
|
|
WCHAR wszFileSystem[MAX_PATH+1] = {0};
|
|
|
|
WCHAR wszBuf[128];
|
|
|
|
BOOL bRet;
|
|
|
|
|
|
|
|
bRet = GetVolumeInformationW(m_wszDrive, wszVolumeName, _countof(wszVolumeName), NULL, NULL, NULL, wszFileSystem, _countof(wszFileSystem));
|
|
|
|
if (bRet)
|
|
|
|
{
|
2012-01-13 17:42:27 +00:00
|
|
|
/* Set volume label and filesystem */
|
2012-01-11 21:58:47 +00:00
|
|
|
SetDlgItemTextW(hwndDlg, 14000, wszVolumeName);
|
|
|
|
SetDlgItemTextW(hwndDlg, 14002, wszFileSystem);
|
|
|
|
}
|
2015-04-22 22:24:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LoadStringW(shell32_hInstance, IDS_FS_UNKNOWN, wszFileSystem, _countof(wszFileSystem));
|
|
|
|
SetDlgItemTextW(hwndDlg, 14002, wszFileSystem);
|
|
|
|
}
|
2012-01-11 21:58:47 +00:00
|
|
|
|
2012-01-13 17:42:27 +00:00
|
|
|
/* Set drive type and icon */
|
2012-01-11 21:58:47 +00:00
|
|
|
UINT DriveType = GetDriveTypeW(m_wszDrive);
|
2012-01-13 17:42:27 +00:00
|
|
|
UINT IconId, TypeStrId = 0;
|
|
|
|
switch (DriveType)
|
2012-01-11 21:58:47 +00:00
|
|
|
{
|
2015-11-08 12:08:59 +00:00
|
|
|
case DRIVE_REMOVABLE: IconId = IDI_SHELL_3_14_FLOPPY; break;
|
2016-01-07 14:04:07 +00:00
|
|
|
case DRIVE_CDROM: IconId = IDI_SHELL_CDROM; TypeStrId = IDS_DRIVE_CDROM; break;
|
|
|
|
case DRIVE_REMOTE: IconId = IDI_SHELL_NETDRIVE; TypeStrId = IDS_DRIVE_NETWORK; break;
|
2012-01-13 17:42:27 +00:00
|
|
|
case DRIVE_RAMDISK: IconId = IDI_SHELL_RAMDISK; break;
|
|
|
|
default: IconId = IDI_SHELL_DRIVE; TypeStrId = IDS_DRIVE_FIXED;
|
|
|
|
}
|
2015-04-22 22:24:46 +00:00
|
|
|
|
2016-08-31 21:15:57 +00:00
|
|
|
if (DriveType == DRIVE_CDROM || DriveType == DRIVE_REMOTE)
|
2015-06-05 07:38:17 +00:00
|
|
|
{
|
|
|
|
/* volume label textbox */
|
2016-08-31 21:15:57 +00:00
|
|
|
SendMessage(GetDlgItem(hwndDlg, 14000), EM_SETREADONLY, TRUE, 0);
|
2015-06-05 07:38:17 +00:00
|
|
|
|
|
|
|
/* disk compression */
|
2016-08-31 21:15:57 +00:00
|
|
|
ShowWindow(GetDlgItem(hwndDlg, 14011), FALSE);
|
2015-04-22 22:24:46 +00:00
|
|
|
|
2015-06-05 07:38:17 +00:00
|
|
|
/* index */
|
2016-08-31 21:15:57 +00:00
|
|
|
ShowWindow(GetDlgItem(hwndDlg, 14012), FALSE);
|
2015-06-05 07:38:17 +00:00
|
|
|
}
|
|
|
|
|
2012-01-13 17:42:27 +00:00
|
|
|
HICON hIcon = (HICON)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IconId), IMAGE_ICON, 32, 32, LR_SHARED);
|
|
|
|
if (hIcon)
|
|
|
|
SendDlgItemMessageW(hwndDlg, 14016, STM_SETICON, (WPARAM)hIcon, 0);
|
|
|
|
if (TypeStrId && LoadStringW(shell32_hInstance, TypeStrId, wszBuf, _countof(wszBuf)))
|
|
|
|
SetDlgItemTextW(hwndDlg, 14001, wszBuf);
|
2012-01-11 21:58:47 +00:00
|
|
|
|
2012-01-13 17:42:27 +00:00
|
|
|
ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes;
|
|
|
|
if(GetDiskFreeSpaceExW(m_wszDrive, &FreeBytesAvailable, &TotalNumberOfBytes, NULL))
|
|
|
|
{
|
|
|
|
/* Init free space percentage used for drawing piechart */
|
|
|
|
m_FreeSpacePerc = (UINT)(FreeBytesAvailable.QuadPart * 100ull / TotalNumberOfBytes.QuadPart);
|
2012-01-11 21:58:47 +00:00
|
|
|
|
2012-01-13 17:42:27 +00:00
|
|
|
/* Used space */
|
|
|
|
if (SH_FormatByteSize(TotalNumberOfBytes.QuadPart - FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
|
|
|
|
SetDlgItemTextW(hwndDlg, 14003, wszBuf);
|
2012-01-11 21:58:47 +00:00
|
|
|
|
2012-01-13 17:42:27 +00:00
|
|
|
if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart - FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
|
|
|
|
SetDlgItemTextW(hwndDlg, 14004, wszBuf);
|
2012-01-11 21:58:47 +00:00
|
|
|
|
2012-01-13 17:42:27 +00:00
|
|
|
/* Free space */
|
|
|
|
if (SH_FormatByteSize(FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
|
|
|
|
SetDlgItemTextW(hwndDlg, 14005, wszBuf);
|
2012-01-11 21:58:47 +00:00
|
|
|
|
2012-01-13 17:42:27 +00:00
|
|
|
if (StrFormatByteSizeW(FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
|
2012-01-11 21:58:47 +00:00
|
|
|
SetDlgItemTextW(hwndDlg, 14006, wszBuf);
|
2012-01-13 17:42:27 +00:00
|
|
|
|
|
|
|
/* Total space */
|
2012-12-28 17:42:50 +00:00
|
|
|
if (SH_FormatByteSize(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
|
2012-01-13 17:42:27 +00:00
|
|
|
SetDlgItemTextW(hwndDlg, 14007, wszBuf);
|
|
|
|
|
|
|
|
if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
|
|
|
|
SetDlgItemTextW(hwndDlg, 14008, wszBuf);
|
2012-01-11 21:58:47 +00:00
|
|
|
}
|
2015-04-22 22:24:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_FreeSpacePerc = 0;
|
|
|
|
|
|
|
|
if (SH_FormatByteSize(0, wszBuf, _countof(wszBuf)))
|
|
|
|
{
|
|
|
|
SetDlgItemTextW(hwndDlg, 14003, wszBuf);
|
|
|
|
SetDlgItemTextW(hwndDlg, 14005, wszBuf);
|
|
|
|
SetDlgItemTextW(hwndDlg, 14007, wszBuf);
|
|
|
|
}
|
|
|
|
if (StrFormatByteSizeW(0, wszBuf, _countof(wszBuf)))
|
|
|
|
{
|
|
|
|
SetDlgItemTextW(hwndDlg, 14004, wszBuf);
|
|
|
|
SetDlgItemTextW(hwndDlg, 14006, wszBuf);
|
|
|
|
SetDlgItemTextW(hwndDlg, 14008, wszBuf);
|
|
|
|
}
|
|
|
|
}
|
2012-01-12 20:10:35 +00:00
|
|
|
|
|
|
|
/* Set drive description */
|
2012-01-11 21:58:47 +00:00
|
|
|
WCHAR wszFormat[50];
|
|
|
|
GetDlgItemTextW(hwndDlg, 14009, wszFormat, _countof(wszFormat));
|
2012-01-12 20:10:35 +00:00
|
|
|
swprintf(wszBuf, wszFormat, m_wszDrive[0]);
|
2012-01-11 21:58:47 +00:00
|
|
|
SetDlgItemTextW(hwndDlg, 14009, wszBuf);
|
2015-06-05 07:38:17 +00:00
|
|
|
|
|
|
|
/* show disk cleanup button only for fixed drives */
|
|
|
|
ShowWindow(GetDlgItem(hwndDlg, 14010), DriveType == DRIVE_FIXED);
|
2012-01-11 21:58:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
CDrvDefExt::GeneralPageProc(
|
|
|
|
HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
LPPROPSHEETPAGEW ppsp = (LPPROPSHEETPAGEW)lParam;
|
|
|
|
if (ppsp == NULL)
|
|
|
|
break;
|
|
|
|
|
2014-04-13 12:20:31 +00:00
|
|
|
CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(ppsp->lParam);
|
2012-01-11 21:58:47 +00:00
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pDrvDefExt);
|
|
|
|
pDrvDefExt->InitGeneralPage(hwndDlg);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
{
|
|
|
|
LPDRAWITEMSTRUCT pDrawItem = (LPDRAWITEMSTRUCT)lParam;
|
|
|
|
|
|
|
|
if (pDrawItem->CtlID >= 14013 && pDrawItem->CtlID <= 14015)
|
|
|
|
{
|
2014-04-13 12:20:31 +00:00
|
|
|
CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
|
2012-01-13 17:42:27 +00:00
|
|
|
pDrvDefExt->PaintStaticControls(hwndDlg, pDrawItem);
|
2012-01-11 21:58:47 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-01-12 20:10:35 +00:00
|
|
|
case WM_PAINT:
|
|
|
|
break;
|
2012-01-11 21:58:47 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
if (LOWORD(wParam) == 14010) /* Disk Cleanup */
|
|
|
|
{
|
2014-04-13 12:20:31 +00:00
|
|
|
CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
|
2012-01-11 21:58:47 +00:00
|
|
|
WCHAR wszBuf[256];
|
|
|
|
DWORD cbBuf = sizeof(wszBuf);
|
|
|
|
|
|
|
|
if (RegGetValueW(HKEY_LOCAL_MACHINE,
|
2015-02-06 00:07:23 +00:00
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\CleanupPath",
|
|
|
|
NULL,
|
|
|
|
RRF_RT_REG_SZ,
|
|
|
|
NULL,
|
|
|
|
(PVOID)wszBuf,
|
|
|
|
&cbBuf) == ERROR_SUCCESS)
|
2012-01-11 21:58:47 +00:00
|
|
|
{
|
|
|
|
WCHAR wszCmd[MAX_PATH];
|
|
|
|
|
|
|
|
StringCbPrintfW(wszCmd, sizeof(wszCmd), wszBuf, pDrvDefExt->m_wszDrive[0]);
|
|
|
|
|
|
|
|
if (ShellExecuteW(hwndDlg, NULL, wszCmd, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
|
|
|
|
ERR("Failed to create cleanup process %ls\n", wszCmd);
|
|
|
|
}
|
|
|
|
}
|
2012-01-14 13:20:38 +00:00
|
|
|
else if (LOWORD(wParam) == 14000) /* Label */
|
2012-01-11 21:58:47 +00:00
|
|
|
{
|
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
}
|
2012-01-14 13:20:38 +00:00
|
|
|
break;
|
|
|
|
case WM_NOTIFY:
|
|
|
|
if (((LPNMHDR)lParam)->hwndFrom == GetParent(hwndDlg))
|
2012-01-11 21:58:47 +00:00
|
|
|
{
|
|
|
|
/* Property Sheet */
|
|
|
|
LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;
|
2012-02-08 21:38:53 +00:00
|
|
|
|
2012-01-11 21:58:47 +00:00
|
|
|
if (lppsn->hdr.code == PSN_APPLY)
|
|
|
|
{
|
2014-04-13 12:20:31 +00:00
|
|
|
CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
|
2012-01-11 21:58:47 +00:00
|
|
|
WCHAR wszBuf[256];
|
|
|
|
|
2012-01-14 13:20:38 +00:00
|
|
|
if (GetDlgItemTextW(hwndDlg, 14000, wszBuf, _countof(wszBuf)))
|
2012-01-11 21:58:47 +00:00
|
|
|
SetVolumeLabelW(pDrvDefExt->m_wszDrive, wszBuf);
|
2018-02-27 21:48:32 +00:00
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
|
2012-01-11 21:58:47 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
CDrvDefExt::ExtraPageProc(
|
|
|
|
HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
LPPROPSHEETPAGEW ppsp = (LPPROPSHEETPAGEW)lParam;
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)ppsp->lParam);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
WCHAR wszBuf[MAX_PATH];
|
|
|
|
DWORD cbBuf = sizeof(wszBuf);
|
2014-04-13 12:20:31 +00:00
|
|
|
CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
|
2012-01-11 21:58:47 +00:00
|
|
|
|
|
|
|
switch(LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case 14000:
|
2012-01-17 21:28:17 +00:00
|
|
|
DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(IDD_CHECK_DISK), hwndDlg, ChkDskDlg, (LPARAM)pDrvDefExt->m_wszDrive);
|
2012-01-11 21:58:47 +00:00
|
|
|
break;
|
|
|
|
case 14001:
|
|
|
|
if (RegGetValueW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\DefragPath",
|
|
|
|
NULL,
|
|
|
|
RRF_RT_REG_SZ,
|
|
|
|
NULL,
|
|
|
|
(PVOID)wszBuf,
|
|
|
|
&cbBuf) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR wszCmd[MAX_PATH];
|
|
|
|
|
|
|
|
StringCbPrintfW(wszCmd, sizeof(wszCmd), wszBuf, pDrvDefExt->m_wszDrive[0]);
|
|
|
|
|
|
|
|
if (ShellExecuteW(hwndDlg, NULL, wszCmd, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
|
|
|
|
ERR("Failed to create defrag process %ls\n", wszCmd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 14002:
|
|
|
|
if (RegGetValueW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\BackupPath",
|
|
|
|
NULL,
|
2015-02-06 00:07:23 +00:00
|
|
|
RRF_RT_REG_SZ,
|
2012-01-11 21:58:47 +00:00
|
|
|
NULL,
|
|
|
|
(PVOID)wszBuf,
|
|
|
|
&cbBuf) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (ShellExecuteW(hwndDlg, NULL, wszBuf, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
|
|
|
|
ERR("Failed to create backup process %ls\n", wszBuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
CDrvDefExt::HardwarePageProc(
|
|
|
|
HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
GUID Guid = GUID_DEVCLASS_DISKDRIVE;
|
|
|
|
|
|
|
|
/* create the hardware page */
|
|
|
|
DeviceCreateHardwarePageEx(hwndDlg, &Guid, 1, HWPD_STANDARDLIST);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CDrvDefExt::CDrvDefExt()
|
|
|
|
{
|
|
|
|
m_wszDrive[0] = L'\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
CDrvDefExt::~CDrvDefExt()
|
|
|
|
{
|
2012-02-08 21:38:53 +00:00
|
|
|
|
2012-01-11 21:58:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
CDrvDefExt::Initialize(LPCITEMIDLIST pidlFolder, IDataObject *pDataObj, HKEY hkeyProgID)
|
|
|
|
{
|
|
|
|
FORMATETC format;
|
|
|
|
STGMEDIUM stgm;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p %p %p %p\n", this, pidlFolder, pDataObj, hkeyProgID);
|
|
|
|
|
|
|
|
if (!pDataObj)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
format.cfFormat = CF_HDROP;
|
|
|
|
format.ptd = NULL;
|
|
|
|
format.dwAspect = DVASPECT_CONTENT;
|
|
|
|
format.lindex = -1;
|
|
|
|
format.tymed = TYMED_HGLOBAL;
|
|
|
|
|
|
|
|
hr = pDataObj->GetData(&format, &stgm);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (!DragQueryFileW((HDROP)stgm.hGlobal, 0, m_wszDrive, _countof(m_wszDrive)))
|
|
|
|
{
|
|
|
|
ERR("DragQueryFileW failed\n");
|
|
|
|
ReleaseStgMedium(&stgm);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseStgMedium(&stgm);
|
|
|
|
TRACE("Drive properties %ls\n", m_wszDrive);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
CDrvDefExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
CDrvDefExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
CDrvDefExt::GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
CDrvDefExt::AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hPage;
|
|
|
|
|
2012-01-17 21:28:17 +00:00
|
|
|
hPage = SH_CreatePropertySheetPage(IDD_DRIVE_PROPERTIES,
|
2012-01-11 21:58:47 +00:00
|
|
|
GeneralPageProc,
|
|
|
|
(LPARAM)this,
|
|
|
|
NULL);
|
|
|
|
if (hPage)
|
|
|
|
pfnAddPage(hPage, lParam);
|
|
|
|
|
|
|
|
if (GetDriveTypeW(m_wszDrive) == DRIVE_FIXED)
|
|
|
|
{
|
2012-01-17 21:28:17 +00:00
|
|
|
hPage = SH_CreatePropertySheetPage(IDD_DRIVE_TOOLS,
|
2012-01-11 21:58:47 +00:00
|
|
|
ExtraPageProc,
|
|
|
|
(LPARAM)this,
|
|
|
|
NULL);
|
|
|
|
if (hPage)
|
|
|
|
pfnAddPage(hPage, lParam);
|
|
|
|
}
|
|
|
|
|
2012-01-17 21:28:17 +00:00
|
|
|
hPage = SH_CreatePropertySheetPage(IDD_DRIVE_HARDWARE,
|
2012-01-11 21:58:47 +00:00
|
|
|
HardwarePageProc,
|
|
|
|
(LPARAM)this,
|
|
|
|
NULL);
|
|
|
|
if (hPage)
|
|
|
|
pfnAddPage(hPage, lParam);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
CDrvDefExt::ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
CDrvDefExt::SetSite(IUnknown *punk)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
CDrvDefExt::GetSite(REFIID iid, void **ppvSite)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|