|
|
|
|
|
Dicas
|
|
Visual Basic (ActiveX/Controles/DLL)
|
|
|
Título da Dica: Formatar discos
|
|
|
|
Postada em 16/2/2006 por ¨Hennyere¨
'Num módulo *.bas
Option Explicit
Private Declare Function SHFormatDrive Lib _ "shell32" (ByVal hwnd As Long, ByVal _ Drive As Long, ByVal fmtID As Long, _ ByVal options As Long) As Long Private Declare Function GetDriveType Lib _ "kernel32" Alias "GetDriveTypeA" _ (ByVal nDrive As String) As Long
Public Const DRIVE_CDROM = 5 Public Const DRIVE_FIXED = 3 Public Const DRIVE_RAMDISK = 6 Public Const DRIVE_REMOTE = 4 Public Const DRIVE_REMOVABLE = 2 Public Const SHFMT_ID_DEFAULT = &HFFFF Public Const SHFMT_OPT_FULL = 1 Public Const SHFMT_OPT_SYSONLY = 2
Public Sub FormatFloppy(hWndOwner As _ Long, ByVal DriveLetter As String) Dim DriveNum As Long, DriveType As Long Dim ret As Long DriveLetter = Left(DriveLetter, 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 "O drive informado não é um " & _ "drive de discos removíveis", _ vbExclamation, "Formatar Disquete" End If End Sub
'No Form Private Sub Command1_Click() FormatFloppy Me.hwnd, "A" 'Neste caso, estaria mandando formatar o drive A:. End Sub
'Josefh Hennyere
|
|
|
|
|