1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Mag Disk Format

Discussion in 'Delphi Components,Freeware, Open Source' started by AdminDF, Dec 2, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    Mag Disk Format (v1.2, 2010.8.12)


    The Check Disk and Format Disk component is a Delphi wrapper around the Windows APIs exported by fmifs.dll, which are used to format fixed or removable disk drives and perform disk checks on Windows NT4 and later. It supports any local disk drive that has been assigned a drive letter by Windows, just like the normal format and check disk tools in Windows.

    The component may be used to format disks which are not currently in-use, and to verify the file system on any drives, but only fix it on drives that are not in-use. It may be useful for preparing removable backup drives.

    These fmifs.dll APIs are undocumented by Microsoft, but were reverse engineering by System Internals. The component is is based on the command line Chkdskx and Formatx applications by Mark Russinovich available from http://www.sysinternals.com/.

    Please note that the fmifs.dll APIs are different from most other Windows APIs and are intended to be interactive with the user, rather than passively accepting input and providing simple output. Specifically, they return progress information that is normally seen in a Windows dialog or in a command line window, showing the steps being taken and reporting any errors or corruption found. This component attempts to parse the messages and provide simple return information. A demo program illustrates the use of all the functions.

    Check Disk

    Example progress doing Check Disk of a USB key. Note this varies depending on the file system type, and whether any errors are discovered.

    Starting Check Disk for H:
    H:\ Volume Label: USBH, File System: NTFS
    Volume label is USBH.
    CHKDSK is verifying files (stage 1 of 3)...
    File verification completed.
    CHKDSK is verifying indexes (stage 2 of 3)...
    Index verification completed.
    CHKDSK is verifying security descriptors (stage 3 of 3)...
    Security descriptor verification completed.
    Windows has checked the file system and found no problems.
    253167 KB total disk space.
    4 KB in 8 indexes.
    0 KB in bad sectors.
    3042 KB in use by the system.
    2544 KB occupied by the log file.
    250121 KB available on disk.
    512 bytes in each allocation unit.
    506335 total allocation units on disk.
    500243 allocation units available on disk.
    Check Disk: Finished OK


    Format Disk

    Example progress formatting a USB key.

    Starting Format Disk for H:
    H:\ Checking Existing Drive Format
    H:\ Volume Label: USBH, File System: NTFS
    H:\ Starting to Format Drive
    Format Disk: Structure Created OK
    Format Disk: Finished OK
    H:\ Checking New Drive Format
    H:\ Volume Label: USBKEY, File System: NTFS
    H:\ New Volume Space: 256124416


    Class TMagFmtChkDsk

    The component may be installed on palette, but is non-visual so it's usually easier to create it in code.

    Types

    TMediaType = (mtHardDisk, mtFloppy) ;

    TFileSystem = (fsNTFS, fsFAT, fsFAT32) ;


    Functions

    LoadFmifs: boolean ;

    Used to load the fmifs.dll APIs, the public variable MagFmifs_Loaded is set True if this succeeds. It's not necessary to call this, since it's done before any other functions.


    function FormatDisk (const DrvRoot: string; MediaType: TMediaType;
    FileSystem: TFileSystem; const DiskLabel: string; QuickFormat: boolean;
    ClusterSize: integer): boolean ;

    This function causes a disk to be formatted. DvrRoot could be ie 'd:\'; MediaType is mtHardDisk or mtFloppy; FileSystem is fsNTFS, fsFAT or fsFAT32; DiskLabel is up to 16 characters, the QuickFormat flag may cause faster formatting is overridden if the file system changes; ClusterSize is 512, 1024, 2048, 4096, 8192, 16384, 32768 or 655536, but format may fail if it's not supported by the file system.

    Returns true if disk is formatted OK. Calls onInfoEvent with ASCII progress information and errors, see example above. Calls onProgressEvent with step percentage completed, to optionally update a progress bar. Both events allow formatting to be cancelled, but this may not be immediately effective. An exception will be raised if the drive can not be found or if it is in-use.

    function CheckDisk (const DrvRoot: string; CorrectErrors, Verbose,
    CheckOnlyIfDirty, ScanDrive: boolean): boolean ;

    This function causes a disk check of the file system to be performed. DvrRoot could be ie 'd:\'; Correct Errors is true if the disk can be written to correct errors; CheckOnlyIfDirty seems to be ignored; ScanDrive is true is a full disk scan should be done.

    Returns true if check disk passes OK. The FileSysProblem will be true if a problem was detected during Check Disk with the FirstErrorLine property containing the first error line, note this may not always be meaningful. The FreeSpaceAlloc property will be true if 'free space marked as allocated' is seen, but this does not fail Check Disk. Calls onInfoEvent with ASCII progress information and errors, see example above. Calls onProgressEvent with step percentage completed, to optionally update a
    progress bar. Both events allow check disk to be cancelled, but this may not be immediately effective. An exception will be raised if the drive can not be found or if it in-use and CorrectErrors is true.


    function VolumeCompression (const DrvRoot: string; Enable: boolean): boolean ;

    This function enables or disable volume compression, if the file system supports compression. DvrRoot could be ie 'd:\'.

    Returns true if compression state is changed OK.


    Properties

    These are effectively results from Check Disk, see above.

    property FileSysProblem: boolean ;
    property FreeSpaceAlloc: boolean ;
    property FirstErrorLine: string ;


    Events

    These events are optional, but allow progress to be displayed or logged.

    onProgressEvent - ProgressEvent (Percent: integer; var Cancel: boolean) ;

    onInfoEvent - InfoEvent (Info: string; var Cancel: boolean) ;


    Demonstration Application

    A Windows demonstration application DISKFMT.EXE is supplied, with source and compiled program.

    History

    v1.1 - Better compatibility with Vista and later, no longer shows an unknown Check Disk callback, more callback messages handled. Also testing the program has administrator rights on start-up with a warning if it will not function.

    v1.2 - Supports Delphi 2009 and 2010, corrected progress message charset which was OEM (IBM-PC) not ANSI or Unicode, thanks to Francois Piette.

    The Check Disk and Format Disk component is copyright by Magenta Systems Ltd, but may be used freely.

    Compatible with Delphi 5/6/7/2005/2006/2007/2009, tested with Windows 2000, XP, 2003, Vista, 2008 and 7.  Delphi 2009 and later versions supports Unicode. 

    Download HERE
     
    paramithas likes this.
  2. dynamo
    Offline

    dynamo DF Expert

    Thank you
     

Share This Page