/* * @implemented */ BOOL WINAPI SetVolumeLabelA(IN LPCSTR lpRootPathName, IN LPCSTR lpVolumeName OPTIONAL) /* NULL if deleting label */ { PWCHAR RootPathNameW; PWCHAR VolumeNameW = NULL; BOOL Result; if (!(RootPathNameW = FilenameA2W(lpRootPathName, FALSE))) return FALSE; if (lpVolumeName) { if (!(VolumeNameW = FilenameA2W(lpVolumeName, TRUE))) return FALSE; } Result = SetVolumeLabelW (RootPathNameW, VolumeNameW); if (VolumeNameW) { RtlFreeHeap (RtlGetProcessHeap (), 0, VolumeNameW ); } return Result; }
nsresult sbWinSetVolumeLabel(const nsAString& aVolumeMountPath, const nsACString& aVolumeLabel) { BOOL success; // Set the volume label. success = SetVolumeLabelW(aVolumeMountPath.BeginReading(), NS_ConvertUTF8toUTF16(aVolumeLabel).get()); NS_ENSURE_TRUE(success, NS_ERROR_FAILURE); return NS_OK; }
static void set_drive_label( char letter, const WCHAR *label ) { static const WCHAR emptyW[1]; WCHAR device[] = {'a',':','\\',0}; /* SetVolumeLabel() requires a trailing slash */ device[0] = letter; if (!label) label = emptyW; if(!SetVolumeLabelW(device, label)) { WINE_WARN("unable to set volume label for devicename of %s, label of %s\n", wine_dbgstr_w(device), wine_dbgstr_w(label)); PRINTERROR(); } else { WINE_TRACE(" set volume label for devicename of %s, label of %s\n", wine_dbgstr_w(device), wine_dbgstr_w(label)); } }
//---------------------------------------------------------------------- // // WMain // // Engine. Just get command line switches and fire off a format. This // could also be done in a GUI like Explorer does when you select a // drive and run a check on it. // // We do this in UNICODE because the chkdsk command expects PWCHAR // arguments. // //---------------------------------------------------------------------- int wmain( int argc, WCHAR *argv[] ) { int badArg; DWORD media; DWORD driveType; WCHAR fileSystem[1024]; WCHAR volumeName[1024]; WCHAR input[1024]; DWORD serialNumber; DWORD flags, maxComponent; ULARGE_INTEGER freeBytesAvailableToCaller, totalNumberOfBytes, totalNumberOfFreeBytes; _tprintf(L"\nFormatx v1.0 by Mark Russinovich\n"); _tprintf(L"Systems Internals - http://www.sysinternals.com\n\n"); // // Get function pointers // if( !LoadFMIFSEntryPoints()) { _tprintf(L"Could not located FMIFS entry points.\n\n"); return -1; } // // Parse command line // if( (badArg = ParseCommandLine( argc, argv ))) { _tprintf(L"Unknown argument: %s\n", argv[badArg] ); Usage(argv[0]); return -1; } // // Get the drive's format // if( !Drive ) { _tprintf(L"Required drive parameter is missing.\n\n"); Usage( argv[0] ); return -1; } else { wcscpy( RootDirectory, Drive ); } RootDirectory[2] = L'\\'; RootDirectory[3] = (WCHAR) 0; // // See if the drive is removable or not // driveType = GetDriveTypeW( RootDirectory ); if( driveType != DRIVE_FIXED ) { _tprintf(L"Insert a new floppy in drive %C:\nand press Enter when ready...", RootDirectory[0] ); fgetws( input, sizeof(input)/2, stdin ); media = FMIFS_FLOPPY; } // // Determine the drive's file system format // if( !GetVolumeInformationW( RootDirectory, volumeName, sizeof(volumeName)/2, &serialNumber, &maxComponent, &flags, fileSystem, sizeof(fileSystem)/2)) { PrintWin32Error( L"Could not query volume", GetLastError()); return -1; } if( !GetDiskFreeSpaceExW( RootDirectory, &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes )) { PrintWin32Error( L"Could not query volume size", GetLastError()); return -1; } _tprintf(L"The type of the file system is %s.\n", fileSystem ); // // Make sure they want to do this // if( driveType == DRIVE_FIXED ) { if( volumeName[0] ) { while(1 ) { _tprintf(L"Enter current volume label for drive %C: ", RootDirectory[0] ); fgetws( input, sizeof(input)/2, stdin ); input[ wcslen( input ) - 1] = 0; if( !wcsicmp( input, volumeName )) { break; } _tprintf(L"An incorrect volume label was entered for this drive.\n"); } } while( 1 ) { _tprintf(L"\nWARNING, ALL DATA ON NON_REMOVABLE DISK\n"); _tprintf(L"DRIVE %C: WILL BE LOST!\n", RootDirectory[0] ); _tprintf(L"Proceed with Format (Y/N)? " ); fgetws( input, sizeof(input)/2, stdin ); if( input[0] == L'Y' || input[0] == L'y' ) break; if( input[0] == L'N' || input[0] == L'n' ) { _tprintf(L"\n"); return 0; } } media = FMIFS_HARDDISK; } // // Tell the user we're doing a long format if appropriate // if( !QuickFormat ) { if( totalNumberOfBytes.QuadPart > 1024*1024*10 ) { _tprintf(L"Verifying %dM\n", (DWORD) (totalNumberOfBytes.QuadPart/(1024*1024))); } else { _tprintf(L"Verifying %.1fM\n", ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0)); } } else { if( totalNumberOfBytes.QuadPart > 1024*1024*10 ) { _tprintf(L"QuickFormatting %dM\n", (DWORD) (totalNumberOfBytes.QuadPart/(1024*1024))); } else { _tprintf(L"QuickFormatting %.2fM\n", ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0)); } _tprintf(L"Creating file system structures.\n"); } // // Format away! // FormatEx( RootDirectory, media, Format, Label, QuickFormat, ClusterSize, FormatExCallback ); if( Error ) return -1; _tprintf(L"Format complete.\n"); // // Enable compression if desired // if( CompressDrive ) { if( !EnableVolumeCompression( RootDirectory, TRUE )) { _tprintf(L"Volume does not support compression.\n"); } } // // Get the label if we don't have it // if( !GotALabel ) { _tprintf(L"Volume Label (11 characters, Enter for none)? " ); fgetws( input, sizeof(LabelString)/2, stdin ); input[ wcslen(input)-1] = 0; if( !SetVolumeLabelW( RootDirectory, input )) { PrintWin32Error(L"Could not label volume", GetLastError()); return -1; } } if( !GetVolumeInformationW( RootDirectory, volumeName, sizeof(volumeName)/2, &serialNumber, &maxComponent, &flags, fileSystem, sizeof(fileSystem)/2)) { PrintWin32Error( L"Could not query volume", GetLastError()); return -1; } // // Print out some stuff including the formatted size // if( !GetDiskFreeSpaceExW( RootDirectory, &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes )) { PrintWin32Error( L"Could not query volume size", GetLastError()); return -1; } _tprintf(L"\n%I64d bytes total disk space.\n", totalNumberOfBytes.QuadPart ); _tprintf(L"%I64d bytes available on disk.\n", totalNumberOfFreeBytes.QuadPart ); // // Get the drive's serial number // if( !GetVolumeInformationW( RootDirectory, volumeName, sizeof(volumeName)/2, &serialNumber, &maxComponent, &flags, fileSystem, sizeof(fileSystem)/2)) { PrintWin32Error( L"Could not query volume", GetLastError()); return -1; } _tprintf(L"\nVolume Serial Number is %04X-%04X\n", serialNumber >> 16, serialNumber & 0xFFFF ); return 0; }
INT_PTR CALLBACK DriveGeneralDlg( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { LPPROPSHEETPAGEW ppsp; LPDRAWITEMSTRUCT drawItem; STARTUPINFOW si; PROCESS_INFORMATION pi; WCHAR * lpstr; WCHAR szPath[MAX_PATH]; UINT length; LPPSHNOTIFY lppsn; switch(uMsg) { case WM_INITDIALOG: ppsp = (LPPROPSHEETPAGEW)lParam; if (ppsp == NULL) break; lpstr = (WCHAR *)ppsp->lParam; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lpstr); InitializeGeneralDriveDialog(hwndDlg, lpstr); return TRUE; case WM_DRAWITEM: drawItem = (LPDRAWITEMSTRUCT)lParam; if (drawItem->CtlID >= 14013 && drawItem->CtlID <= 14015) { PaintStaticControls(hwndDlg, drawItem); return TRUE; } break; case WM_COMMAND: if (LOWORD(wParam) == 14010) /* Disk Cleanup */ { lpstr = (WCHAR*)GetWindowLongPtr(hwndDlg, DWLP_USER); ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); if (!GetSystemDirectoryW(szPath, MAX_PATH)) break; wcscat(szPath, L"\\cleanmgr.exe /D "); length = wcslen(szPath); szPath[length] = lpstr[0]; szPath[length+1] = L'\0'; if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } break; } case WM_NOTIFY: lppsn = (LPPSHNOTIFY) lParam; if (LOWORD(wParam) == 14000) { if (HIWORD(wParam) == EN_CHANGE) { PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; } if (lppsn->hdr.code == PSN_APPLY) { lpstr = (LPWSTR)GetWindowLongPtr(hwndDlg, DWLP_USER); if (lpstr && SendDlgItemMessageW(hwndDlg, 14000, WM_GETTEXT, sizeof(szPath)/sizeof(WCHAR), (LPARAM)szPath)) { szPath[(sizeof(szPath)/sizeof(WCHAR))-1] = L'\0'; SetVolumeLabelW(lpstr, szPath); } SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR ); return TRUE; } break; default: break; } return FALSE; }
static VOID Test(PWSTR Prefix) { static PWSTR Sddl = L"D:P(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;WD)"; static const GUID ReparseGuid = { 0x2cf25cfa, 0x41af, 0x4796, { 0xb5, 0xef, 0xac, 0xa3, 0x85, 0x3, 0xe2, 0xd8 } }; WCHAR FileName[1024], VolumeName[MAX_PATH]; PSECURITY_DESCRIPTOR SecurityDescriptor; HANDLE Handle; BOOL Success; UINT8 RdBuffer[4096], WrBuffer[4096]; REPARSE_GUID_DATA_BUFFER ReparseDataBuf; DWORD BytesTransferred, Offset; WIN32_FIND_DATAW FindData; WIN32_FIND_STREAM_DATA FindStreamData; memset(WrBuffer, 'B', sizeof WrBuffer); Success = ConvertStringSecurityDescriptorToSecurityDescriptorW( Sddl, SDDL_REVISION_1, &SecurityDescriptor, 0); ASSERT(Success); wsprintfW(FileName, L"%s\\", Prefix); Success = GetVolumeInformationW(FileName, VolumeName, MAX_PATH, 0, 0, 0, 0, 0); ASSERT(Success); wsprintfW(FileName, L"%s\\", Prefix); Success = SetVolumeLabelW(FileName, VolumeName); //ASSERT(Success); wsprintfW(FileName, L"%s\\fscrash", Prefix); Success = CreateDirectoryW(FileName, 0); ASSERT(Success); wsprintfW(FileName, L"%s\\fscrash\\file0", Prefix); Handle = CreateFileW(FileName, GENERIC_ALL, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); ASSERT(INVALID_HANDLE_VALUE != Handle); Success = CloseHandle(Handle); ASSERT(Success); wsprintfW(FileName, L"%s\\fscrash\\file0", Prefix); Handle = CreateFileW(FileName, GENERIC_ALL, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); ASSERT(INVALID_HANDLE_VALUE != Handle); Success = WriteFile(Handle, WrBuffer, sizeof WrBuffer, &BytesTransferred, 0); ASSERT(Success); ASSERT(sizeof WrBuffer == BytesTransferred); Success = FlushFileBuffers(Handle); ASSERT(Success); Offset = SetFilePointer(Handle, 0, 0, FILE_BEGIN); ASSERT(0 == Offset); Success = ReadFile(Handle, RdBuffer, sizeof RdBuffer, &BytesTransferred, 0); ASSERT(Success); ASSERT(sizeof WrBuffer == BytesTransferred); Offset = SetFilePointer(Handle, 0, 0, FILE_BEGIN); ASSERT(0 == Offset); Success = SetEndOfFile(Handle); ASSERT(Success); Offset = GetFileSize(Handle, 0); ASSERT(0 == Offset); Success = LockFile(Handle, 0, 0, 1, 0); ASSERT(Success); Success = UnlockFile(Handle, 0, 0, 1, 0); ASSERT(Success); Success = SetKernelObjectSecurity(Handle, DACL_SECURITY_INFORMATION, SecurityDescriptor); ASSERT(Success); Success = GetKernelObjectSecurity(Handle, DACL_SECURITY_INFORMATION, 0, 0, &BytesTransferred); ASSERT(!Success); ASSERT(ERROR_INSUFFICIENT_BUFFER == GetLastError()); ReparseDataBuf.ReparseTag = 0x1234; ReparseDataBuf.ReparseDataLength = 0; ReparseDataBuf.Reserved = 0; memcpy(&ReparseDataBuf.ReparseGuid, &ReparseGuid, sizeof ReparseGuid); Success = DeviceIoControl(Handle, FSCTL_SET_REPARSE_POINT, &ReparseDataBuf, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE + ReparseDataBuf.ReparseDataLength, 0, 0, &BytesTransferred, 0); ASSERT(Success); Success = CloseHandle(Handle); ASSERT(Success); wsprintfW(FileName, L"%s\\fscrash\\*", Prefix); Handle = FindFirstFileW(FileName, &FindData); ASSERT(INVALID_HANDLE_VALUE != Handle); do { } while (FindNextFileW(Handle, &FindData)); ASSERT(ERROR_NO_MORE_FILES == GetLastError()); Success = FindClose(Handle); ASSERT(Success); wsprintfW(FileName, L"%s\\fscrash\\file0", Prefix); Handle = FindFirstStreamW(FileName, FindStreamInfoStandard, &FindStreamData, 0); ASSERT(INVALID_HANDLE_VALUE != Handle); do { } while (FindNextStreamW(Handle, &FindStreamData)); ASSERT(ERROR_HANDLE_EOF == GetLastError()); Success = FindClose(Handle); ASSERT(Success); wsprintfW(FileName, L"%s\\fscrash\\file0", Prefix); Success = DeleteFileW(FileName); ASSERT(Success); wsprintfW(FileName, L"%s\\fscrash", Prefix); Success = RemoveDirectoryW(FileName); ASSERT(Success); LocalFree(SecurityDescriptor); }
//---------------------------------------------------------------------- // // WMain // // Engine. Just get command line switches and fire off a format. This // could also be done in a GUI like Explorer does when you select a // drive and run a check on it. // // We do this in UNICODE because the chkdsk command expects PWCHAR // arguments. // //---------------------------------------------------------------------- int wmain(int argc, WCHAR *argv[]) { int badArg; DWORD media = FMIFS_HARDDISK; DWORD driveType; WCHAR fileSystem[1024]; WCHAR volumeName[1024]; WCHAR input[1024]; DWORD serialNumber; DWORD flags, maxComponent; ULARGE_INTEGER freeBytesAvailableToCaller, totalNumberOfBytes, totalNumberOfFreeBytes; WCHAR szMsg[RC_STRING_MAX_SIZE]; wprintf(L"\n" L"Formatx v1.0 by Mark Russinovich\n" L"Systems Internals - http://www.sysinternals.com\n" L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n"); #ifndef FMIFS_IMPORT_DLL // // Get function pointers // if (!LoadFMIFSEntryPoints()) { PrintResourceString(STRING_FMIFS_FAIL); return -1; } #endif // // Parse command line // badArg = ParseCommandLine(argc, argv); if (badArg) { PrintResourceString(STRING_UNKNOW_ARG, argv[badArg]); Usage(argv[0]); return -1; } // // Get the drive's format // if (!Drive) { PrintResourceString(STRING_DRIVE_PARM); Usage(argv[0]); return -1; } else { wcscpy(RootDirectory, Drive); } RootDirectory[2] = L'\\'; RootDirectory[3] = L'\0'; // // See if the drive is removable or not // driveType = GetDriveTypeW(RootDirectory); switch (driveType) { case DRIVE_UNKNOWN : LoadStringW(GetModuleHandle(NULL), STRING_ERROR_DRIVE_TYPE, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; case DRIVE_REMOTE: case DRIVE_CDROM: PrintResourceString(STRING_NO_SUPPORT); return -1; case DRIVE_NO_ROOT_DIR: LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; case DRIVE_REMOVABLE: PrintResourceString(STRING_INSERT_DISK, RootDirectory[0]); fgetws(input, ARRAYSIZE(input), stdin); media = FMIFS_FLOPPY; break; case DRIVE_FIXED: case DRIVE_RAMDISK: media = FMIFS_HARDDISK; break; } // Reject attempts to format the system drive { WCHAR path[MAX_PATH + 1]; UINT rc; rc = GetWindowsDirectoryW(path, MAX_PATH); if (rc == 0 || rc > MAX_PATH) // todo: Report "Unable to query system directory" return -1; if (towlower(path[0]) == towlower(Drive[0])) { // todo: report "Cannot format system drive" PrintResourceString(STRING_NO_SUPPORT); return -1; } } // // Determine the drive's file system format // if (!GetVolumeInformationW(RootDirectory, volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponent, &flags, fileSystem, ARRAYSIZE(fileSystem))) { LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } if (!GetDiskFreeSpaceExW(RootDirectory, &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes)) { LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } PrintResourceString(STRING_FILESYSTEM, fileSystem); // // Make sure they want to do this // if (driveType == DRIVE_FIXED) { if (volumeName[0]) { while (TRUE) { PrintResourceString(STRING_LABEL_NAME_EDIT, RootDirectory[0]); fgetws(input, ARRAYSIZE(input), stdin); input[wcslen(input) - 1] = 0; if (!wcsicmp(input, volumeName)) break; PrintResourceString(STRING_ERROR_LABEL); } } PrintResourceString(STRING_YN_FORMAT, RootDirectory[0]); LoadStringW(GetModuleHandle(NULL), STRING_YES_NO_FAQ, szMsg, ARRAYSIZE(szMsg)); while (TRUE) { fgetws(input, ARRAYSIZE(input), stdin); if (_wcsnicmp(&input[0], &szMsg[0], 1) == 0) break; if (_wcsnicmp(&input[0], &szMsg[1], 1) == 0) { wprintf(L"\n"); return 0; } } } // // Tell the user we're doing a long format if appropriate // if (!QuickFormat) { LoadStringW(GetModuleHandle(NULL), STRING_VERIFYING, szMsg, ARRAYSIZE(szMsg)); if (totalNumberOfBytes.QuadPart > 1024*1024*10) { PrintString(L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024))); } else { PrintString(L"%s %.1fM\n", szMsg, ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0)); } } else { LoadStringW(GetModuleHandle(NULL), STRING_FAST_FMT, szMsg, ARRAYSIZE(szMsg)); if (totalNumberOfBytes.QuadPart > 1024*1024*10) { PrintString(L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024))); } else { PrintString(L"%s %.2fM\n", szMsg, ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0)); } PrintResourceString(STRING_CREATE_FSYS); } // // Format away! // FormatEx(RootDirectory, media, FileSystem, Label, QuickFormat, ClusterSize, FormatExCallback); if (Error) return -1; PrintResourceString(STRING_FMT_COMPLETE); // // Enable compression if desired // if (CompressDrive) { if (!EnableVolumeCompression(RootDirectory, TRUE)) PrintResourceString(STRING_VOL_COMPRESS); } // // Get the label if we don't have it // if (!GotALabel) { PrintResourceString(STRING_ENTER_LABEL); fgetws(input, ARRAYSIZE(LabelString), stdin); input[wcslen(input) - 1] = 0; if (!SetVolumeLabelW(RootDirectory, input)) { LoadStringW(GetModuleHandle(NULL), STRING_NO_LABEL, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } } if (!GetVolumeInformationW(RootDirectory, volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponent, &flags, fileSystem, ARRAYSIZE(fileSystem))) { LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } // // Print out some stuff including the formatted size // if (!GetDiskFreeSpaceExW(RootDirectory, &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes)) { LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } PrintResourceString(STRING_FREE_SPACE, totalNumberOfBytes.QuadPart, totalNumberOfFreeBytes.QuadPart); // // Get the drive's serial number // if (!GetVolumeInformationW(RootDirectory, volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponent, &flags, fileSystem, ARRAYSIZE(fileSystem))) { LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } PrintResourceString(STRING_SERIAL_NUMBER, (unsigned int)(serialNumber >> 16), (unsigned int)(serialNumber & 0xFFFF)); return 0; }
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; CDrvDefExt *pDrvDefExt = (CDrvDefExt*)ppsp->lParam; 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) { CDrvDefExt *pDrvDefExt = (CDrvDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); pDrvDefExt->PaintStaticControls(hwndDlg, pDrawItem); return TRUE; } break; } case WM_PAINT: break; case WM_COMMAND: if (LOWORD(wParam) == 14010) /* Disk Cleanup */ { CDrvDefExt *pDrvDefExt = (CDrvDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); WCHAR wszBuf[256]; DWORD cbBuf = sizeof(wszBuf); if (RegGetValueW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\CleanupPath", 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 cleanup process %ls\n", wszCmd); } } else if (LOWORD(wParam) == 14000) /* Label */ { if (HIWORD(wParam) == EN_CHANGE) PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->hwndFrom == GetParent(hwndDlg)) { /* Property Sheet */ LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam; if (lppsn->hdr.code == PSN_APPLY) { CDrvDefExt *pDrvDefExt = (CDrvDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); WCHAR wszBuf[256]; if (GetDlgItemTextW(hwndDlg, 14000, wszBuf, _countof(wszBuf))) SetVolumeLabelW(pDrvDefExt->m_wszDrive, wszBuf); SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR); return TRUE; } } break; default: break; } return FALSE; }