CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    69

    Format disk programmatically

    How do I bring up the format disk dialog box from my program?


  2. #2
    Join Date
    Apr 1999
    Location
    Sofia, Bulgaria
    Posts
    57

    Re: Format disk programmatically

    SHFormatDrive pops the standard Windows format dialog.

    extern "C" {
    WINBASEAPI
    LONG
    WINAPI SHFormatDrive( HWND hParent , LONG drive, LONG p3, LONG p4);
    }
    from SHELL32.DLL

    hParent = parent window hwnd
    drive = A: 0, B: 1, C: 2, etc.

    you have to experiment with it a little.
    Have in mind that it is undocumented (you will not find it in header files or documentation). And returns different values on 95 and NT:
    Under NT it returns nonzero on success. The third and fourth paramters are not used on NT (or i do not know what they are used for - however NT's WinDisk calls it with p3=0xFFFF, p4 = 0)

    Under 95 it returns 0 on success. The p3 (or p4) parameter tell the system to format the disk with system files (quick format etc.)

    By all means you should investigate the problem because right now I do not have my sources to be more specific.



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

Featured