[FMIFS]
[reactos.git] / reactos / dll / win32 / shell32 / dialogs / drive.cpp
1 /*
2 * Shell Library Functions
3 *
4 * Copyright 2005 Johannes Anderwald
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "precomp.h"
22
23 #define MAX_PROPERTY_SHEET_PAGE 32
24
25 WINE_DEFAULT_DEBUG_CHANNEL(shell);
26
27 typedef struct
28 {
29 WCHAR Drive;
30 UINT Options;
31 UINT Result;
32 } FORMAT_DRIVE_CONTEXT, *PFORMAT_DRIVE_CONTEXT;
33
34 EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj);
35 HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle);
36
37 static BOOL
38 GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
39 {
40 DWORD ClusterSize;
41
42 if (!wcsicmp(szFs, L"FAT16") ||
43 !wcsicmp(szFs, L"FAT")) //REACTOS HACK
44 {
45 if (TotalNumberOfBytes->QuadPart <= (16 * 1024 * 1024))
46 ClusterSize = 2048;
47 else if (TotalNumberOfBytes->QuadPart <= (32 * 1024 * 1024))
48 ClusterSize = 512;
49 else if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
50 ClusterSize = 1024;
51 else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
52 ClusterSize = 2048;
53 else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
54 ClusterSize = 4096;
55 else if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024))
56 ClusterSize = 8192;
57 else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024))
58 ClusterSize = 16384;
59 else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL))
60 ClusterSize = 32768;
61 else if (TotalNumberOfBytes->QuadPart <= (4096LL * 1024LL * 1024LL))
62 ClusterSize = 8192;
63 else
64 return FALSE;
65 }
66 else if (!wcsicmp(szFs, L"FAT32"))
67 {
68 if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
69 ClusterSize = 512;
70 else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
71 ClusterSize = 1024;
72 else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
73 ClusterSize = 2048;
74 else if (TotalNumberOfBytes->QuadPart <= (8192LL * 1024LL * 1024LL))
75 ClusterSize = 2048;
76 else if (TotalNumberOfBytes->QuadPart <= (16384LL * 1024LL * 1024LL))
77 ClusterSize = 8192;
78 else if (TotalNumberOfBytes->QuadPart <= (32768LL * 1024LL * 1024LL))
79 ClusterSize = 16384;
80 else
81 return FALSE;
82 }
83 else if (!wcsicmp(szFs, L"NTFS"))
84 {
85 if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024))
86 ClusterSize = 512;
87 else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024))
88 ClusterSize = 1024;
89 else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL))
90 ClusterSize = 2048;
91 else
92 ClusterSize = 2048;
93 }
94 else if (!wcsicmp(szFs, L"EXT2"))
95 {
96 // auto block size calculation
97 ClusterSize = 0;
98 }
99 else
100 return FALSE;
101
102 *pClusterSize = ClusterSize;
103 return TRUE;
104 }
105
106 static BOOL CALLBACK
107 AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
108 {
109 PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
110 if (ppsh->nPages < MAX_PROPERTY_SHEET_PAGE)
111 {
112 ppsh->phpage[ppsh->nPages++] = hPage;
113 return TRUE;
114 }
115 return FALSE;
116 }
117
118 typedef struct _DRIVE_PROP_PAGE
119 {
120 LPCSTR resname;
121 DLGPROC dlgproc;
122 UINT DriveType;
123 } DRIVE_PROP_PAGE;
124
125 BOOL
126 SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl)
127 {
128 HPSXA hpsx = NULL;
129 HPROPSHEETPAGE hpsp[MAX_PROPERTY_SHEET_PAGE];
130 PROPSHEETHEADERW psh;
131 CComObject<CDrvDefExt> *pDrvDefExt = NULL;
132 WCHAR wszName[256];
133
134 ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
135 psh.dwSize = sizeof(PROPSHEETHEADERW);
136 psh.dwFlags = 0; // FIXME: make it modeless
137 psh.hwndParent = NULL;
138 psh.nStartPage = 0;
139 psh.phpage = hpsp;
140
141 LPITEMIDLIST completePidl = ILCombine(pidlFolder, apidl[0]);
142 if (!completePidl)
143 return FALSE;
144
145 if (ILGetDisplayNameExW(NULL, completePidl, wszName, ILGDN_NORMAL))
146 {
147 psh.pszCaption = wszName;
148 psh.dwFlags |= PSH_PROPTITLE;
149 }
150
151 ILFree(completePidl);
152
153 CComPtr<IDataObject> pDataObj;
154 HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_PPV_ARG(IDataObject, &pDataObj));
155
156 if (SUCCEEDED(hr))
157 {
158 hr = CComObject<CDrvDefExt>::CreateInstance(&pDrvDefExt);
159 if (SUCCEEDED(hr))
160 {
161 pDrvDefExt->AddRef(); // CreateInstance returns object with 0 ref count
162 hr = pDrvDefExt->Initialize(pidlFolder, pDataObj, NULL);
163 if (SUCCEEDED(hr))
164 {
165 hr = pDrvDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&psh);
166 if (FAILED(hr))
167 ERR("AddPages failed\n");
168 } else
169 ERR("Initialize failed\n");
170 }
171
172 hpsx = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Drive", MAX_PROPERTY_SHEET_PAGE, pDataObj);
173 if (hpsx)
174 SHAddFromPropSheetExtArray(hpsx, (LPFNADDPROPSHEETPAGE)AddPropSheetPageCallback, (LPARAM)&psh);
175 }
176
177 HWND hwnd = (HWND)PropertySheetW(&psh);
178
179 if (hpsx)
180 SHDestroyPropSheetExtArray(hpsx);
181 if (pDrvDefExt)
182 pDrvDefExt->Release();
183
184 if (!hwnd)
185 return FALSE;
186 return TRUE;
187 }
188
189 static VOID
190 InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
191 {
192 WCHAR wszBuf[100] = {0};
193 WCHAR szDrive[] = L"C:\\";
194 INT iSelIndex;
195 ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
196 DWORD ClusterSize;
197 LRESULT lIndex;
198 HWND hDlgCtrl;
199
200 hDlgCtrl = GetDlgItem(hwndDlg, 28677);
201 iSelIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, 0, 0);
202 if (iSelIndex == CB_ERR)
203 return;
204
205 if (SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)wszBuf) == CB_ERR)
206 return;
207
208 szDrive[0] = pContext->Drive + L'A';
209
210 if (!GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
211 return;
212
213 if (!wcsicmp(wszBuf, L"FAT16") ||
214 !wcsicmp(wszBuf, L"FAT")) //REACTOS HACK
215 {
216 if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
217 {
218 TRACE("FAT16 is not supported on hdd larger than 4G current %lu\n", TotalNumberOfBytes.QuadPart);
219 SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
220 return;
221 }
222
223 if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
224 {
225 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
226 SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
227 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
228 if (lIndex != CB_ERR)
229 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
230 SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
231 }
232
233 SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
234 EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
235 }
236 else if (!wcsicmp(wszBuf, L"FAT32"))
237 {
238 if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
239 {
240 TRACE("FAT32 is not supported on hdd larger than 32G current %lu\n", TotalNumberOfBytes.QuadPart);
241 SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
242 return;
243 }
244
245 if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
246 {
247 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
248 SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
249 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
250 if (lIndex != CB_ERR)
251 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
252 SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
253 }
254
255 SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
256 EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
257 }
258 else if (!wcsicmp(wszBuf, L"NTFS"))
259 {
260 if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
261 {
262 TRACE("NTFS is not supported on hdd larger than 2TB current %lu\n", TotalNumberOfBytes.QuadPart);
263 SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
264 return;
265 }
266
267 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
268 if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
269 {
270 SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
271 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
272 if (lIndex != CB_ERR)
273 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
274 SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
275 }
276 ClusterSize = 512;
277 for (lIndex = 0; lIndex < 4; lIndex++)
278 {
279 TotalNumberOfBytes.QuadPart = ClusterSize;
280 if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
281 {
282 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
283 if (lIndex != CB_ERR)
284 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
285 }
286 ClusterSize *= 2;
287 }
288
289 EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
290 }
291 else if (!wcsicmp(wszBuf, L"EXT2"))
292 {
293 if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
294 {
295 TRACE("EXT2 is not supported on hdd larger than 32T current %lu\n", TotalNumberOfBytes.QuadPart);
296 SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
297 return;
298 }
299
300 if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
301 {
302 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
303 SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
304 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
305 if (lIndex != CB_ERR)
306 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
307 SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
308 }
309
310 EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
311 }
312 else
313 {
314 FIXME("unknown fs\n");
315 SendDlgItemMessageW(hwndDlg, 28680, CB_RESETCONTENT, iSelIndex, 0);
316 return;
317 }
318 }
319
320 static VOID
321 InitializeFormatDriveDlg(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
322 {
323 WCHAR szText[120];
324 WCHAR szDrive[] = L"C:\\";
325 WCHAR szFs[30] = L"";
326 INT cchText;
327 ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
328 DWORD dwIndex, dwDefault;
329 UCHAR uMinor, uMajor;
330 BOOLEAN Latest;
331 HWND hwndFileSystems;
332
333 cchText = GetWindowTextW(hwndDlg, szText, _countof(szText) - 1);
334 if (cchText < 0)
335 cchText = 0;
336 szText[cchText++] = L' ';
337 szDrive[0] = pContext->Drive + L'A';
338 if (GetVolumeInformationW(szDrive, &szText[cchText], _countof(szText) - cchText, NULL, NULL, NULL, szFs, _countof(szFs)))
339 {
340 if (szText[cchText] == UNICODE_NULL)
341 {
342 /* load default volume label */
343 cchText += LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, &szText[cchText], _countof(szText) - cchText);
344 }
345 else
346 {
347 /* set volume label */
348 SetDlgItemTextW(hwndDlg, 28679, &szText[cchText]);
349 cchText += wcslen(&szText[cchText]);
350 }
351 }
352
353 StringCchPrintfW(szText + cchText, _countof(szText) - cchText, L" (%c:)", szDrive[0]);
354
355 /* set window text */
356 SetWindowTextW(hwndDlg, szText);
357
358 if (GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
359 {
360 if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szText, _countof(szText)))
361 {
362 /* add drive capacity */
363 SendDlgItemMessageW(hwndDlg, 28673, CB_ADDSTRING, 0, (LPARAM)szText);
364 SendDlgItemMessageW(hwndDlg, 28673, CB_SETCURSEL, 0, (LPARAM)0);
365 }
366 }
367
368 if (pContext->Options & SHFMT_OPT_FULL)
369 {
370 /* check quick format button */
371 SendDlgItemMessageW(hwndDlg, 28674, BM_SETCHECK, BST_CHECKED, 0);
372 }
373
374 /* enumerate all available filesystems */
375 dwIndex = 0;
376 dwDefault = 0;
377 hwndFileSystems = GetDlgItem(hwndDlg, 28677);
378
379 while(QueryAvailableFileSystemFormat(dwIndex, szText, &uMajor, &uMinor, &Latest))
380 {
381 if (!wcsicmp(szText, szFs))
382 dwDefault = dwIndex;
383
384 SendMessageW(hwndFileSystems, CB_ADDSTRING, 0, (LPARAM)szText);
385 dwIndex++;
386 }
387
388 if (!dwIndex)
389 {
390 ERR("no filesystem providers\n");
391 return;
392 }
393
394 /* select default filesys */
395 SendMessageW(hwndFileSystems, CB_SETCURSEL, dwDefault, 0);
396 /* setup cluster combo */
397 InsertDefaultClusterSizeForFs(hwndDlg, pContext);
398 /* hide progress control */
399 ShowWindow(GetDlgItem(hwndDlg, 28678), SW_HIDE);
400 }
401
402 static HWND FormatDrvDialog = NULL;
403 static BOOLEAN bSuccess = FALSE;
404
405 static BOOLEAN NTAPI
406 FormatExCB(
407 IN CALLBACKCOMMAND Command,
408 IN ULONG SubAction,
409 IN PVOID ActionInfo)
410 {
411 PDWORD Progress;
412 PBOOLEAN pSuccess;
413 switch(Command)
414 {
415 case PROGRESS:
416 Progress = (PDWORD)ActionInfo;
417 SendDlgItemMessageW(FormatDrvDialog, 28678, PBM_SETPOS, (WPARAM)*Progress, 0);
418 break;
419 case DONE:
420 pSuccess = (PBOOLEAN)ActionInfo;
421 bSuccess = (*pSuccess);
422 break;
423
424 case VOLUMEINUSE:
425 case INSUFFICIENTRIGHTS:
426 case FSNOTSUPPORTED:
427 case CLUSTERSIZETOOSMALL:
428 bSuccess = FALSE;
429 FIXME("\n");
430 break;
431
432 default:
433 break;
434 }
435
436 return TRUE;
437 }
438
439 VOID
440 FormatDrive(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
441 {
442 WCHAR szDrive[4] = { L'C', ':', '\\', 0 };
443 WCHAR szFileSys[40] = {0};
444 WCHAR szLabel[40] = {0};
445 INT iSelIndex;
446 UINT Length;
447 HWND hDlgCtrl;
448 BOOL QuickFormat;
449 DWORD ClusterSize;
450
451 /* set volume path */
452 szDrive[0] = pContext->Drive + L'A';
453
454 /* get filesystem */
455 hDlgCtrl = GetDlgItem(hwndDlg, 28677);
456 iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
457 if (iSelIndex == CB_ERR)
458 {
459 FIXME("\n");
460 return;
461 }
462 Length = SendMessageW(hDlgCtrl, CB_GETLBTEXTLEN, iSelIndex, 0);
463 if ((int)Length == CB_ERR || Length + 1 > _countof(szFileSys))
464 {
465 FIXME("\n");
466 return;
467 }
468
469 /* retrieve the file system */
470 SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)szFileSys);
471 szFileSys[_countof(szFileSys)-1] = L'\0';
472
473 /* retrieve the volume label */
474 hDlgCtrl = GetWindow(hwndDlg, 28679);
475 Length = SendMessageW(hDlgCtrl, WM_GETTEXTLENGTH, 0, 0);
476 if (Length + 1 > _countof(szLabel))
477 {
478 FIXME("\n");
479 return;
480 }
481 SendMessageW(hDlgCtrl, WM_GETTEXT, _countof(szLabel), (LPARAM)szLabel);
482 szLabel[(sizeof(szLabel)/sizeof(WCHAR))-1] = L'\0';
483
484 /* check for quickformat */
485 if (SendDlgItemMessageW(hwndDlg, 28674, BM_GETCHECK, 0, 0) == BST_CHECKED)
486 QuickFormat = TRUE;
487 else
488 QuickFormat = FALSE;
489
490 /* get the cluster size */
491 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
492 iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
493 if (iSelIndex == CB_ERR)
494 {
495 FIXME("\n");
496 return;
497 }
498 ClusterSize = SendMessageW(hDlgCtrl, CB_GETITEMDATA, iSelIndex, 0);
499 if ((int)ClusterSize == CB_ERR)
500 {
501 FIXME("\n");
502 return;
503 }
504
505 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
506 ShowWindow(hDlgCtrl, SW_SHOW);
507 SendMessageW(hDlgCtrl, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
508 bSuccess = FALSE;
509
510 /* FIXME
511 * will cause display problems
512 * when performing more than one format
513 */
514 FormatDrvDialog = hwndDlg;
515
516 FormatEx(szDrive,
517 FMIFS_HARDDISK, /* FIXME */
518 szFileSys,
519 szLabel,
520 QuickFormat,
521 ClusterSize,
522 FormatExCB);
523
524 ShowWindow(hDlgCtrl, SW_HIDE);
525 FormatDrvDialog = NULL;
526 if (!bSuccess)
527 {
528 pContext->Result = SHFMT_ERROR;
529 }
530 else if (QuickFormat)
531 {
532 pContext->Result = SHFMT_OPT_FULL;
533 }
534 else
535 {
536 pContext->Result = FALSE;
537 }
538 }
539
540 static INT_PTR CALLBACK
541 FormatDriveDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
542 {
543 PFORMAT_DRIVE_CONTEXT pContext;
544
545 switch(uMsg)
546 {
547 case WM_INITDIALOG:
548 InitializeFormatDriveDlg(hwndDlg, (PFORMAT_DRIVE_CONTEXT)lParam);
549 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam);
550 return TRUE;
551 case WM_COMMAND:
552 switch(LOWORD(wParam))
553 {
554 case IDOK:
555 pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
556 FormatDrive(hwndDlg, pContext);
557 break;
558 case IDCANCEL:
559 pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
560 EndDialog(hwndDlg, pContext->Result);
561 break;
562 case 28677: // filesystem combo
563 if (HIWORD(wParam) == CBN_SELENDOK)
564 {
565 pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
566 InsertDefaultClusterSizeForFs(hwndDlg, pContext);
567 }
568 break;
569 }
570 }
571 return FALSE;
572 }
573
574 /*************************************************************************
575 * SHFormatDrive (SHELL32.@)
576 */
577
578 DWORD
579 WINAPI
580 SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
581 {
582 FORMAT_DRIVE_CONTEXT Context;
583 int result;
584
585 TRACE("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
586
587 Context.Drive = drive;
588 Context.Options = options;
589
590 result = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(IDD_FORMAT_DRIVE), hwnd, FormatDriveDlg, (LPARAM)&Context);
591
592 return result;
593 }
594
595