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.
23 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
39 ////////////////////////////////////////////////////////////////////////////////
44 void ConfigureDriveBar(HWND hDriveBar
)
46 static DWORD dwLogicalDrivesSaved
;
47 DWORD dwLogicalDrives
= GetLogicalDrives();
49 if (!hDriveBar
) return;
51 if (dwLogicalDrives
!= dwLogicalDrivesSaved
) {
52 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, TBSTYLE_SEP
};
56 int count
= SendMessage(hDriveBar
, TB_BUTTONCOUNT
, 0, 0);
58 SendMessage(hDriveBar
, TB_DELETEBUTTON
, (WPARAM
)--count
, 0);
60 count
= SendMessage(Globals
.hDriveCombo
, CB_GETCOUNT
, 0, 0);
62 // SendMessage(Globals.hDriveCombo, CB_DELETESTRING, (WPARAM)--count, 0);
64 SendMessage(Globals
.hDriveCombo
, CB_RESETCONTENT
, 0, 0);
66 memset(Globals
.drives
, 0, BUFFER_LEN
);
67 GetLogicalDriveStrings(BUFFER_LEN
, Globals
.drives
);
68 drivebarBtn
.fsStyle
= TBSTYLE_BUTTON
;
69 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
70 for (p
= Globals
.drives
; *p
;) {
71 // insert drive letter
72 // TCHAR b[3] = { tolower(*p) };
73 // SendMessage(hDriveBar, TB_ADDSTRING, 0, (LPARAM)b);
74 TCHAR szVolumeNameBuffer
[MAX_PATH
];
75 TCHAR vol
[MAX_PATH
] = { tolower(*p
) };
76 SendMessage(hDriveBar
, TB_ADDSTRING
, 0, (LPARAM
)vol
);
77 switch(GetDriveType(p
)) {
78 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
79 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
80 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
81 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
82 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
84 SendMessage(hDriveBar
, TB_INSERTBUTTON
, btn
, (LPARAM
)&drivebarBtn
);
86 vol
[0] = toupper(vol
[0]);
87 vol
[1] = _T(':'); vol
[2] = _T('\\'); vol
[3] = _T('\0');
88 if (drivebarBtn
.iBitmap
!= 1 /*DRIVE_REMOVABLE*/ &&
89 GetVolumeInformation(vol
, szVolumeNameBuffer
,
90 sizeof(szVolumeNameBuffer
)/sizeof(TCHAR
),
91 NULL
, NULL
, NULL
, NULL
, 0) &&
92 szVolumeNameBuffer
[0] != _T('\0')) {
93 vol
[2] = _T(' '); vol
[3] = _T('['); vol
[4] = _T('\0');
94 _tcscat(vol
, szVolumeNameBuffer
);
95 _tcscat(vol
, _T("] "));
99 // cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE;
100 cbei
.mask
= CBEIF_TEXT
/* | CBEIF_IMAGE*/;
101 cbei
.iItem
= btn
- 1;
103 cbei
.cchTextMax
= _tcslen(cbei
.pszText
);
104 cbei
.iImage
= drivebarBtn
.iBitmap
;
105 // cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
106 // cbei.iIndent = IInf[iCnt].iIndent;
107 SendMessage(Globals
.hDriveCombo
, CBEM_INSERTITEM
, 0, (LPARAM
)&cbei
);
109 drivebarBtn
.idCommand
++;
110 drivebarBtn
.iString
++;
114 dwLogicalDrivesSaved
= dwLogicalDrives
;
115 // SendMessage(Globals.hDriveCombo, CB_SHOWDROPDOWN, (WPARAM)TRUE, (LPARAM)0);
129 } ITEMINFO, *PITEMINFO;
132 { 0, 3, 0, _T("A:")},
133 { 1, 4, 1, _T("C: [SYSTEM]")},
134 { 2, 5, 2, _T("D:")},
135 { 0, 3, 0, _T("E: [SOFT_RAID_1]")},
136 { 1, 4, 1, _T("F: [DATAVOL]")},
137 { 2, 5, 2, _T("sixth")},
138 { 0, 3, 0, _T("seventh")},
144 for (iCnt = 0; iCnt < MAX_ITEMS; iCnt++) {
145 // cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE;
146 cbei.mask = CBEIF_TEXT;
148 cbei.pszText = IInf[iCnt].pszText;
149 // cbei.cchTextMax = sizeof(IInf[iCnt].pszText);
150 cbei.cchTextMax = _tcslen(IInf[iCnt].pszText);
151 // cbei.iImage = IInf[iCnt].iImage;
152 // cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
153 // cbei.iIndent = IInf[iCnt].iIndent;
154 SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
161 void _GetFreeSpaceEx(void)
164 TCHAR szDrive
[MAX_PATH
];
165 ULARGE_INTEGER i64FreeBytesToCaller
;
166 ULARGE_INTEGER i64TotalBytes
;
167 ULARGE_INTEGER i64FreeBytes
;
169 fResult
= GetDiskFreeSpaceEx(szDrive
,
170 (PULARGE_INTEGER
)&i64FreeBytesToCaller
,
171 (PULARGE_INTEGER
)&i64TotalBytes
,
172 (PULARGE_INTEGER
)&i64FreeBytes
);