home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / memsz331.zip / Source.zip / SVDISK.H < prev    next >
C/C++ Source or Header  |  1996-09-03  |  2KB  |  70 lines

  1. // Definitions for accessing Albert Shan's SVDisk device driver.
  2.  
  3. #ifndef SVDISK_H
  4. #define SVDISK_H
  5.  
  6. #define SVDISKKEY (0x8ACE4007)
  7. #define SVD_QUERYSTATUS (0xFF)
  8.  
  9. #pragma pack(1)
  10.  
  11.    typedef struct { 
  12.       USHORT BytesPerSector; 
  13.       UCHAR  SectorsPerCluster; 
  14.       USHORT ReservedSectors; 
  15.       UCHAR  NumberOfFATs; 
  16.       USHORT RootEntries; 
  17.       USHORT TotalSectors; 
  18.       UCHAR  MediaDescriptor; 
  19.       USHORT SectorsPerFAT; 
  20.       USHORT SectorsPerTrack; 
  21.       USHORT Heads; 
  22.       ULONG  HiddenSectors; 
  23.       ULONG  BigTotalSectors; 
  24.       UCHAR  Reserved[6]; 
  25.    } BPB; 
  26.    
  27.    typedef struct { 
  28.       BPB    DeviceBPB; 
  29.       USHORT NumberOfCylinders; 
  30.       UCHAR  DeviceType; 
  31.       USHORT DeviceAttributes; 
  32.    } DEVICEPARM; 
  33.  
  34.    typedef struct _SVD {
  35.       ULONG Key ;
  36.       USHORT Command ;
  37.       USHORT Version ;
  38.       ULONG MediaSize ;
  39.       ULONG DeviceSize ;
  40.       ULONG LockBase ;
  41.       ULONG LockSize ;
  42.       USHORT Error ;
  43.       UCHAR Dummy ;
  44.       DEVICEPARM DeviceParm ;
  45.    } SVD, *PSVD ;
  46.  
  47. #pragma pack()
  48.  
  49. #ifdef __cplusplus
  50.  
  51.    inline BOOL IsSVDisk ( UCHAR Unit ) {
  52.       UCHAR Parms [2] = { 0, (UCHAR)(Unit-1) } ;
  53.       SVD Disk ;
  54.       Disk.Command = SVD_QUERYSTATUS ;
  55.       Disk.Version = 0xFFFF ;
  56.       Disk.Key = SVDISKKEY ;
  57.       ULONG ParmLen = sizeof(Parms), DataLen = sizeof(Disk) ;
  58.       APIRET Result = DosDevIOCtl ( -1, IOCTL_DISK, DSK_GETDEVICEPARAMS, 
  59.          (PVOID)Parms, ParmLen, &ParmLen, (PVOID)&Disk, DataLen, &DataLen ) ;
  60.       if ( Result ) 
  61.          return ( FALSE ) ;
  62.       if ( Disk.Key != SVDISKKEY ) 
  63.          return ( FALSE ) ;
  64.       return ( TRUE ) ;
  65.    } /* endfunction */
  66.  
  67. #endif // If C++
  68.  
  69. #endif // If not already included.
  70.