Reply-To: "Todd M. Eischeid" From: "Todd M. Eischeid" Newsgroups: borland.public.delphi.objectpascal References: <3cbbca7f$1_1@dnews> Subject: Re: How to tell if a drive is Iomega Zip Drive? Date: Wed, 17 Apr 2002 17:13:56 -0400 Lines: 165 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 208.59.196.112 Message-ID: <3cbde52e_1@dnews> X-Trace: dnews 1019077934 208.59.196.112 (17 Apr 2002 14:12:14 -0700) Path: dnews Xref: dnews borland.public.delphi.objectpascal:238032 Eric, Below are a set of functions I wrote to Delphi-ize the Win API functions for drive information. For Zip drives the type will be dtRemovable and TDriveInfo.DiskSize will return a number around 98078 (but only if there is a zip disk in the drive; otherwise the DiskSize value will be zero) Regards, Todd Eischeid ******************************** type TDriveType = (dtUnknown, dtDoesNotExist, dtRemovable, dtFixed, dtNetwork, dtCDROM, dtRAMDisk); type TDriveInfo = record DriveLetter: string; DriveType: TDriveType; TypeDescrip: string; DriveSize: single; //size in Kilobytes DriveFreeSpace: single; //free space in Kilobytes end; type TDriveInfoArray = array of TDriveInfo; //pass a single character string as the 'DriveLetter' param function DriveType(DriveLetter: string): TDriveType; var x, DrvType : Integer; DrvLetter, DrvString : String; begin result := dtUnknown; DriveLetter := DriveLetter + ':\'; // get the drive type DrvType := GetDriveType(pChar(DriveLetter)); // set our drive type string accordingly case DrvType of 0 : result := dtUnknown; 1 : result := dtDoesNotExist; DRIVE_REMOVABLE : result := dtRemovable; DRIVE_FIXED : result := dtFixed; DRIVE_REMOTE : result := dtNetwork; DRIVE_CDROM : result := dtCDROM; DRIVE_RAMDISK : result := dtRAMDisk; end; end; //returns a listing of all drives and types on the system procedure GetAllDriveTypes(var DriveInfoArray: TDriveInfoArray); var x: integer; begin DriveInfoArray := nil; SetLength(DriveInfoArray, 0); //25 possible drives ... a-z for x := Ord('A') to Ord('Z') do begin if not ( DriveType(Chr(x)) = dtDoesNotExist) then begin SetLength(DriveInfoArray, Length(DriveInfoArray) + 1); DriveInfoArray[Length(DriveInfoArray) - 1].DriveLetter := Chr(x); DriveInfoArray[Length(DriveInfoArray) - 1].DriveType := DriveType(Chr(x)); DriveInfoArray[Length(DriveInfoArray) - 1].TypeDescrip := DriveTypeToString(DriveInfoArray[Length(DriveInfoArray) - 1].DriveType); DriveInfoArray[Length(DriveInfoArray) - 1].DriveSize := DiskSize(x - 64) / 1024; //size in KB DriveInfoArray[Length(DriveInfoArray) - 1].DriveFreeSpace := DiskFree(x - 64) / 1024; //size in KB end; end; end; function DriveTypeToString(DriveType: TDriveType): string; begin case DriveType of dtUnknown: result := 'Unknown Drive Type'; dtDoesNotExist: result := 'Drive Does Not Exist'; dtRemovable: result := 'Removable Drive'; dtFixed: result := 'Fixed Drive'; dtNetwork: result := 'Network Drive'; dtCDROM: result := 'CD-ROM Drive'; dtRAMDisk: result := 'RAM Disk Drive'; end; end; //Returns true if the drive is ready (useful for removable drives) function DriveReady(DriveLetter: string): boolean; var code: Integer; rec: TSearchRec; EMode: Word; begin EMode := SetErrorMode(SEM_FAILCRITICALERRORS); DriveLetter := AnsiLowerCase(DriveLetter); //FYI, ord('a') = 97 try result := (DiskSize( Ord(DriveLetter[1]) - 96 ) <> -1) finally SetErrorMode(EMode); end; end; *********************************************** "Eric Jansen" wrote in message news:3cbbca7f$1_1@dnews... > "Gene Weinbeck" wrote in message > news:b5tmbu864ipn93mofigjaq79aubvft905l@4ax.com... > > Is there a way to determine if a drive is an Iomega Zip drive? or any > > other high-capacity removable media? > > > > GetDriveType will tell you if the disk is removable, GetDiskFreeSpace(Ex) > the disk size. > > hth > -- > Eric Jansen > > Find your answers at: > Newsgroups archives: http://groups.google.com > Torry's Delphi Pages: http://www.torry.net > Delphi Super Page: http://delphi.icm.edu.pl