|
|
1.1 ! root 1: Sample: Determining Drive and File System Type ! 2: ! 3: Summary: ! 4: ! 5: A demonstration of how the GetDriveType and ! 6: GetVolumeInformation functions determine all logical drives ! 7: on a system, their disk type (local, remote, CD-ROM, and so ! 8: on), and their file system type (FAT, HPFS, and so on) is ! 9: available in a sample file named DRIVES. ! 10: ! 11: More Information: ! 12: ! 13: The additional API functions, GetLogicalDrives and ! 14: GetLogicalDriveStrings, are not required to determine the ! 15: drive and file system type, but are included as an example ! 16: of how these API functions can enhance the efficiency of ! 17: disk querying API calls. ! 18: ! 19: When a drive type is removable (for example, a floppy disk ! 20: drive), then additional precautions are taken before ! 21: accessing this drive. A validation check is made to see if ! 22: media exists in the drive before proceeding. A simple test ! 23: of opening any file in the root directory of the removable ! 24: media drive using the OpenFile API function determines the ! 25: media's presence. If the OpenFile call returns a handle, ! 26: then media is present and further disk querying calls are ! 27: safely made on the logical drive. If the OpenFile call ! 28: fails, then no media is present and no further attempts to ! 29: query this drive are allowed. Note: in order to eliminate an ! 30: unwanted pop-up, prompting the user to insert a disk in the ! 31: drive, from being generated by the operating system, the ! 32: error mode is temporarily adjusted, using SetErrorMode, to ! 33: allow any OpenFile errors to immediately return to the ! 34: calling routine. ! 35: ! 36: The Win32 API functions used in this sample include the ! 37: following: ! 38: ! 39: GetDriveType GetVolumeInform SetErrorMode ! 40: ation ! 41: GetLogicalDrives lclose ! 42: GetLogicalDriveS OpenFile ! 43: trings ! 44: ! 45: ! 46:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.