6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
43 ////////////////////////////////////////////////////////////////////////////////
48 void ConfigureDriveBar(HWND hDriveBar
)
50 static DWORD dwLogicalDrivesSaved
;
51 DWORD dwLogicalDrives
= GetLogicalDrives();
53 if (!hDriveBar
) return;
55 if (dwLogicalDrives
!= dwLogicalDrivesSaved
) {
56 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, TBSTYLE_SEP
};
60 int count
= SendMessage(hDriveBar
, TB_BUTTONCOUNT
, 0, 0);
62 SendMessage(hDriveBar
, TB_DELETEBUTTON
, (WPARAM
)--count
, 0);
64 count
= SendMessage(Globals
.hDriveCombo
, CB_GETCOUNT
, 0, 0);
66 // SendMessage(Globals.hDriveCombo, CB_DELETESTRING, (WPARAM)--count, 0);
68 SendMessage(Globals
.hDriveCombo
, CB_RESETCONTENT
, 0, 0);
70 memset(Globals
.drives
, 0, BUFFER_LEN
);
71 GetLogicalDriveStrings(BUFFER_LEN
, Globals
.drives
);
72 drivebarBtn
.fsStyle
= TBSTYLE_BUTTON
;
73 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
74 for (p
= Globals
.drives
; *p
;) {
75 // insert drive letter
76 // TCHAR b[3] = { tolower(*p) };
77 // SendMessage(hDriveBar, TB_ADDSTRING, 0, (LPARAM)b);
78 TCHAR szVolumeNameBuffer
[MAX_PATH
];
79 TCHAR vol
[MAX_PATH
] = { tolower(*p
) };
80 SendMessage(hDriveBar
, TB_ADDSTRING
, 0, (LPARAM
)vol
);
81 switch(GetDriveType(p
)) {
82 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
83 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
84 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
85 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
86 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
88 SendMessage(hDriveBar
, TB_INSERTBUTTON
, btn
, (LPARAM
)&drivebarBtn
);
90 vol
[0] = toupper(vol
[0]);
91 vol
[1] = _T(':'); vol
[2] = _T('\\'); vol
[3] = _T('\0');
92 if (drivebarBtn
.iBitmap
!= 1 /*DRIVE_REMOVABLE*/ &&
93 GetVolumeInformation(vol
, szVolumeNameBuffer
,
94 sizeof(szVolumeNameBuffer
)/sizeof(TCHAR
),
95 NULL
, NULL
, NULL
, NULL
, 0) &&
96 szVolumeNameBuffer
[0] != _T('\0')) {
97 vol
[2] = _T(' '); vol
[3] = _T('['); vol
[4] = _T('\0');
98 _tcscat(vol
, szVolumeNameBuffer
);
99 _tcscat(vol
, _T("] "));
103 // cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE;
104 cbei
.mask
= CBEIF_TEXT
/* | CBEIF_IMAGE*/;
105 cbei
.iItem
= btn
- 1;
107 cbei
.cchTextMax
= _tcslen(cbei
.pszText
);
108 cbei
.iImage
= drivebarBtn
.iBitmap
;
109 // cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
110 // cbei.iIndent = IInf[iCnt].iIndent;
111 SendMessage(Globals
.hDriveCombo
, CBEM_INSERTITEM
, 0, (LPARAM
)&cbei
);
113 drivebarBtn
.idCommand
++;
114 drivebarBtn
.iString
++;
118 dwLogicalDrivesSaved
= dwLogicalDrives
;
119 // SendMessage(Globals.hDriveCombo, CB_SHOWDROPDOWN, (WPARAM)TRUE, (LPARAM)0);
132 } ITEMINFO, *PITEMINFO;
135 { 0, 3, 0, _T("A:")},
136 { 1, 4, 1, _T("C: [SYSTEM]")},
137 { 2, 5, 2, _T("D:")},
138 { 0, 3, 0, _T("E: [SOFT_RAID_1]")},
139 { 1, 4, 1, _T("F: [DATAVOL]")},
140 { 2, 5, 2, _T("sixth")},
141 { 0, 3, 0, _T("seventh")},
147 for (iCnt = 0; iCnt < MAX_ITEMS; iCnt++) {
148 // cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE;
149 cbei.mask = CBEIF_TEXT;
151 cbei.pszText = IInf[iCnt].pszText;
152 // cbei.cchTextMax = sizeof(IInf[iCnt].pszText);
153 cbei.cchTextMax = _tcslen(IInf[iCnt].pszText);
154 // cbei.iImage = IInf[iCnt].iImage;
155 // cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
156 // cbei.iIndent = IInf[iCnt].iIndent;
157 SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
164 void _GetFreeSpaceEx(void)
167 TCHAR szDrive
[MAX_PATH
];
168 ULARGE_INTEGER i64FreeBytesToCaller
;
169 ULARGE_INTEGER i64TotalBytes
;
170 ULARGE_INTEGER i64FreeBytes
;
172 fResult
= GetDiskFreeSpaceEx(szDrive
,
173 (PULARGE_INTEGER
)&i64FreeBytesToCaller
,
174 (PULARGE_INTEGER
)&i64TotalBytes
,
175 (PULARGE_INTEGER
)&i64FreeBytes
);