Results 1 to 2 of 2

Thread: Formatting a disk from within VB..

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    West Hartford, CT, USA
    Posts
    42

    Post

    Does anyone know of a way to format a disk (specifically a floppy) from within VB?

    TIA

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Sure! You can use undocumented SHFormatDrive API.

    Code:
    Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwnd As Long, ByVal Drive As Long, ByVal fmtID As Long, ByVal options As Long) As Long
    
    Public Sub FormatDrive(pstrDriveLetter As String)
        Dim intDriveNumber As Integer
        
        'This is for the second parameter
        'drive number: A: is 0, B: is 1 and so on...
        intDriveNumber = UCase(Asc(pstrDriveLetter)) - 65
        Call SHFormatDrive(Me.hwnd, intDriveNumber, 0, 0)
    End Sub
    Usage: FormatDrive DriveToFormat
    Example: Call FormatDrive("a:")

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819



    [This message has been edited by Serge (edited 12-06-1999).]

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