Partager via


DefragVolume (Windows CE 5.0)

Send Feedback

This function defragments files on a volume and removes any free space in fragmentation. The function also calls ScanVolumeEx prior to defragmentation to verify that the volume does not contain errors.

BOOL DefragVolume(
HANDLEhVolume,PDISK_INFOpdi,PDEFRAG_OPTIONSpdo,PFN_PROGRESSpfnProgress,PFN_MESSAGEpfnMessage);

Parameters

  • hVolume
    [in] Handle to a disk or partition. Call CreateFile to obtain a handle to the volume.
  • pdi
    [in] Pointer to a DISK_INFO structure. This pointer can be obtained through a DeviceIoControl call to the appropriate drive with the condition code IOCTL_DISK_GETINFO.
  • pdo
    [in] Pointer to a DEFRAG_OPTIONS structure. The following fields can be specified.
    Member Description
    fVerifyFix TRUE if prompts user to perform a fix.
    dwFatToUse Indicates which FAT to use for scanning, one-based indexing.
  • pfnProgress
    [in] Callback function indicating progress.
  • pfnMessage
    [in] Callback function used to display a message to user.

Return Values

If the function succeeds, the return value is TRUE. If it fails, the return valid is FALSE. Typical reasons for failing would be running out of memory or error writing to disk. Function does not fail if error were detected on disk.

Remarks

For best results, use the correct type of handle. For example, if the store to be scanned is partitioned, use a handle to the partition. If the store is not partitioned, use a disk handle.

Requirements

OS Versions: Windows CE .NET 4.0 and later.

Header: Defragdisk.h.

Link Library: Fatutil.dll.

See Also

CreateFile | DEFRAG_OPTIONS | DISK_INFO | DeviceIoControl

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.