ReactOS 0.4.16-dev-963-g182f353
CSelectDriveDlg.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Disk Cleanup
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Drive selection dialog
5 * COPYRIGHT: Copyright 2023-2025 Mark Jansen <mark.jansen@reactos.org>
6 */
7
8#include "cleanmgr.h"
9
10class CSelectDriveDlg : public CDialogImpl<CSelectDriveDlg>
11{
12public:
13 enum { IDD = IDD_SELECTDRIVE };
14
20
23 {
24 }
25
27 {
28 // Try to find an existing instance of this dialog
29 WCHAR buf[300];
31 for (HWND hNext = NULL, hFind; (hFind = ::FindWindowExW(NULL, hNext, NULL, buf)) != NULL; hNext = hFind)
32 {
33 if (hFind != *this && ::IsWindowVisible(hFind))
34 {
37 return FALSE;
38 }
39 }
40
42 WCHAR VolumeNameBuffer[MAX_PATH + 1];
43 CStringW Tmp;
44 for (WCHAR Drive = 'A'; Drive <= 'Z'; ++Drive)
45 {
46 WCHAR RootPathName[] = { Drive,':','\\',0 };
47 UINT Type = GetDriveTypeW(RootPathName);
48 if (Type == DRIVE_FIXED)
49 {
50 GetVolumeInformationW(RootPathName, VolumeNameBuffer, _countof(VolumeNameBuffer), 0, 0, 0, 0, 0);
51 Tmp.Format(L"%s (%.2s)", VolumeNameBuffer, RootPathName);
52
55 }
56 }
58 return 1;
59 }
61 {
64 EndDialog(wID);
65 return 0;
66 }
67
69};
70
71
72void
74{
75 CSelectDriveDlg dlgSelectDrive;
76 if (dlgSelectDrive.DoModal() == IDOK)
77 {
78 Drive = dlgSelectDrive.m_SelectedDrive;
79 }
80}
void SelectDrive(WCHAR &Drive)
Type
Definition: Type.h:7
#define IDD_SELECTDRIVE
Definition: resource.h:20
#define IDC_DRIVES
Definition: resource.h:21
PWCHAR Drive
Definition: chkdsk.c:73
BOOL EndDialog(_In_ int nRetCode)
Definition: atlwin.h:1519
INT_PTR DoModal(HWND hWndParent=::GetActiveWindow(), LPARAM dwInitParam=0)
Definition: atlwin.h:1504
PXSTR GetString() noexcept
Definition: atlsimpstr.h:367
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1116
BOOL IsWindowVisible() const
Definition: atlwin.h:958
LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL &)
LRESULT OnEndDialog(WORD, WORD wID, HWND, BOOL &)
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MESSAGE_HANDLER(msg, func)
Definition: atlwin.h:1926
#define BEGIN_MSG_MAP(theClass)
Definition: atlwin.h:1898
#define COMMAND_ID_HANDLER(id, func)
Definition: atlwin.h:1953
#define END_MSG_MAP()
Definition: atlwin.h:1917
unsigned int UINT
Definition: ndis.h:50
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:70
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1394
#define DRIVE_FIXED
Definition: winbase.h:278
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define CB_SETITEMDATA
Definition: winuser.h:1969
#define IDCANCEL
Definition: winuser.h:834
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define CB_SETCURSEL
Definition: winuser.h:1964
#define WM_INITDIALOG
Definition: winuser.h:1742
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:833
HWND WINAPI FindWindowExW(_In_opt_ HWND, _In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
#define CB_ADDSTRING
Definition: winuser.h:1939
#define CB_GETITEMDATA
Definition: winuser.h:1953
#define CB_GETCURSEL
Definition: winuser.h:1946
__wchar_t WCHAR
Definition: xmlstorage.h:180