|
Вызвать окно "Форматирование: Диск А:" |
|
|
Private Declare Function SHFormatDrive Lib "shell32.dll" (ByVal hwnd As
Long, ByVal Drive As Long, ByVal fmtID As Long, ByVal options As Long) As Long
Private Declare Function GetDriveType Lib "kernel32.dll" Alias
"GetDriveTypeA" (ByVal nDrive As String) As Long
Const DRIVE_CDROM = 5
Const DRIVE_FIXED = 3
Const DRIVE_RAMDISK = 6
Const DRIVE_REMOTE = 4
Const DRIVE_REMOVABLE = 2
Const SHFMT_ID_DEFAULT = &HFFFF ' Option bits for options parameter
Const SHFMT_OPT_FULL = 1
Const SHFMT_OPT_SYSONLY = 2
Public Sub FormatFloppy(hWndOwner As Long, ByVal DriveLetter As String)
Dim DriveNum As Long
Dim DriveType As Long
Dim ret As Long
DriveLetter = Left(DriveLetter, 1) & ":\"
' Преобразование имени диска в номер устройства:
A=0, B=1...
DriveNum = Asc(UCase(DriveLetter)) - Asc("A")
DriveType = GetDriveType(DriveLetter)
' проверка, а флоппи ли это...
If DriveType = DRIVE_REMOVABLE Then
ret = SHFormatDrive(hWndOwner, DriveNum, SHFMT_ID_DEFAULT, SHFMT_OPT_FULL)
Else
MsgBox "Это не флоппи!", vbExclamation
End If
End Sub
Private Sub Command1_Click()
FormatFloppy Me.hwnd, "A"
End Sub
|
|
|
|
|
|
|