请问大侠,有没有api能够知道硬盘是否已经被格式化过?在线等待!急!

解决方案 »

  1.   

    好像没有这样的API,可以试着读取分区表看看。
      

  2.   

    不如判断一下磁盘剩余空间是否等于总空间
    BOOL GetDiskFreeSpace(
      LPCTSTR lpRootPathName,    // pointer to root path
      LPDWORD lpSectorsPerCluster,  // pointer to sectors per cluster
      LPDWORD lpBytesPerSector,  // pointer to bytes per sector
      LPDWORD lpNumberOfFreeClusters,
                                 // pointer to number of free clusters
      LPDWORD lpTotalNumberOfClusters 
                                 // pointer to total number of clusters
    );
    Parameters
    lpRootPathName 
    Pointer to a null-terminated string that specifies the root directory of the disk to return information about. If lpRootPathName is NULL, the function uses the root of the current directory. If this parameter is a UNC name, you must follow it with an additional backslash. For example, you would specify \\MyServer\MyShare as \\MyServer\MyShare\. 
    Windows 95: The initial release of Windows 95 does not support UNC paths for the lpszRootPathName parameter. To query the free disk space using a UNC path, temporarily map the UNC path to a drive letter, query the free disk space on the drive, then remove the temporary mapping. Windows 95 OSR2 and later: UNC paths are supported. lpSectorsPerCluster 
    Pointer to a variable for the number of sectors per cluster. 
    lpBytesPerSector 
    Pointer to a variable for the number of bytes per sector. 
    lpNumberOfFreeClusters 
    Pointer to a variable for the total number of free clusters on the disk that are available to the user associated with the calling thread. 
    Windows NT 5.0 and later: If per-user disk quotas are in use, this value may be less than the total number of free clusters on the disk. lpTotalNumberOfClusters 
    Pointer to a variable for the total number of clusters on the disk that are available to the user associated with the calling thread.
      

  3.   

    BOOL GetDiskFreeSpaceEx(
      LPCTSTR lpDirectoryName,                 // pointer to the directory name
      PULARGE_INTEGER lpFreeBytesAvailableToCaller, // receives the number of bytes on
                                                    // disk available to the caller
      PULARGE_INTEGER lpTotalNumberOfBytes,    // receives the number of bytes on disk
      PULARGE_INTEGER lpTotalNumberOfFreeBytes // receives the free bytes on disk
    );
     
    Parameters
    lpDirectoryName 
    Pointer to a null-terminated string that specifies a directory on the disk of interest. This string can be a UNC name. If this parameter is a UNC name, you must follow it with an additional backslash. For example, you would specify \\MyServer\MyShare as \\MyServer\MyShare\. 
    If lpDirectoryName is NULL, the GetDiskFreeSpaceEx function obtains information about the disk that contains the current directory. Note that lpDirectoryName does not have to specify the root directory on a disk. The function accepts any directory on the disk. lpFreeBytesAvailableToCaller 
    Pointer to a variable to receive the total number of free bytes on the disk that are available to the user associated with the calling thread. 
    Windows NT 5.0 and later: If per-user quotas are in use, this value may be less than the total number of free bytes on the disk. lpTotalNumberOfBytes 
    Pointer to a variable to receive the total number of bytes on the disk that are available to the user associated with the calling thread. 
    Windows NT 5.0 and later: If per-user quotas are in use, this value may be less than the total number of bytes on the disk. lpTotalNumberOfFreeBytes 
    Pointer to a variable to receive the total number of free bytes on the disk. 
    This parameter can be NULL.