Results 1 to 4 of 4

Thread: Formatting a Disk through API

  1. #1
    Guest

    Exclamation

    Hi, I was wondering about how you format a disk through the API.

    I already know how to do a LONG format, but does anyone
    know how to do a quickformat?

    Thanks in advance.

  2. #2
    New Member
    Join Date
    May 2000
    Posts
    7
    can i see the long way? maybe i can modify it.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    mrvb...here is some code...

    'format a drive
    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

    Private Sub Command1_Click()
    Dim DriveLetter$, DriveNumber&, DriveType&
    Dim RetVal&, RetFromMsg%
    DriveLetter = UCase(Drive1.Drive)
    DriveNumber = (Asc(DriveLetter) - 65) ' Change letter to Number: A=0
    DriveType = GetDriveType(DriveLetter)


    If DriveType = 2 Then 'Floppies, etc
    RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
    Else
    RetFromMsg = MsgBox("This drive is NOT a removeable" & vbCrLf & _
    "drive! Format this drive?", 276, "SHFormatDrive Example")


    Select Case RetFromMsg
    Case 6 'Yes
    ' UnComment to do it...
    'RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
    Case 7 'No
    ' Do nothing
    End Select

    End If

    End Sub



    Private Sub Command2_Click()
    ' DiskCopyRunDll takes two parameters- From and To
    Dim DriveLetter$, DriveNumber&, DriveType&
    Dim RetVal&, RetFromMsg&
    DriveLetter = UCase(Drive1.Drive)
    DriveNumber = (Asc(DriveLetter) - 65)
    DriveType = GetDriveType(DriveLetter)


    If DriveType = 2 Then 'Floppies, etc
    RetVal = Shell("rundll32.exe diskcopy.dll,DiskCopyRunDll " _
    & DriveNumber & "," & DriveNumber, 1) 'Notice space after
    Else ' Just in Case 'DiskCopyRunDll
    RetFromMsg = MsgBox("Only floppies can" & vbCrLf & _
    "be diskcopied!", 64, "DiskCopy Example")
    End If

    End Sub

    'Add 1 ListDrive name Drive1

    Private Sub Drive1_Change()

    Dim DriveLetter$, DriveNumber&, DriveType&
    DriveLetter = UCase(Drive1.Drive)
    DriveNumber = (Asc(DriveLetter) - 65)
    DriveType = GetDriveType(DriveLetter)


    If DriveType = 2 Then 'Floppies, etc
    Command2.Enabled = False
    Else
    Command2.Enabled = True
    End If

    End Sub

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    Guest

    Red face Gee, Thx <sarcasm>

    Gee, that's the FOURTH EXAMPLE I've gotten from Planet Source Code.

    I DO NOT want to bring up the Windows Format Dialog..


    Thx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width