# Include "DriveInfoLx. h" # Include <e32base. h> # Include <e32std. h> # Include <e32cons. h> // Console # Include <f32file. h>// Constants _ Partition (KTextConsoleTitle, "Console "); _ Blank (KTextFailed, "failed, leave code = % d "); _ Keys (KTextPressAnyKey, "[press any key] \ n "); // Global Variables LOCAL_D CConsoleBase * console; // write all messages to this RFs ifs; // Local Functions Void formatDriveInfo (TDes & abuf, TDriveInfo & di ); Void printDriveInfo () { User: LeaveIfError (ifs. Connect ()); TDriveInfo di; TBuf <256> buf; TInt driverNumber = EDriveA; For (; driverNumber <= EDriveZ; driverNumber ++) { Ifs. Drive (di, driverNumber ); If (di. iDriveAtt = KDriveAbsent) Continue;
FormatDriveInfo (buf, di ); Buf. Delete (0, buf. Length ()); Console-> Getch (); } Ifs. Close (); } Void formatDriveInfo (TDes & abuf, TDriveInfo & di) { _ Partition (KFormatString, "iType = % 02x, iDriveAtt = % 02x, iMediaAtt = % 02x \ n "); _ Partition (KBatLow, "Battery low \ n "); _ Partition (KBatgood, "Battery good \ n "); _ Partition (KBatNotsupported, "Battery not supported "); _ Representation (KNotPresent, "No media present \ n "); _ Snapshot (Kfloppy, "Media is floppy disk \ n "); _ Partition (KHard, "Media is hard disk \ n "); _ Weight (KCDROM, "Media is CD-ROM \ n "); _ Queue (KRam, "Media is RAM \ n "); _ Weight (KRom, "Media is ROM \ n "); _ Seek (KFlash, "Media is flash \ n "); _ Metadata (KRemote, "Media is remote \ n "); _ Unknown (KUnknown, "Media is unknown \ n "); _ Attributes (KDriveAtts, "Drive attributes :"); _ Partition (KLocal, "local "); _ Category (KRomDrive, "Rom "); _ Commit (KRedirected, "redirected "); _ Partition (KSubstituted, "substituted "); _ Partition (KInternal, "internal "); _ Removeable (KRemoveable, "removeable "); _ Partition (KDynamic, "dynamic "); _ Partition (KDual, "dual-desity "); _ Partition (KFormattable, "formattable "); _ Partition (KWriteProtected, "write-protected "); _ Partition (KnewLine, "\ n "); _ Attributes (KMediaAtts, "\ nMedia attributes :"); Abuf. AppendFormat (KFormatString, TInt (di. iType), TInt (di. iBattery), TInt (di. iDriveAtt) , TInt (di. iMediaAtt )); Switch (di. iBattery) { Case EBatLow: Abuf. Append (KBatLow ); Break; Case EBatGood: Abuf. Append (KBatgood ); Break; Default: Abuf. Append (KBatNotsupported ); } Switch (di. iType) { Case EMediaNotPresent: Abuf. Append (KNotPresent ); Break; Case EMediaFloppy: Abuf. Append (Kfloppy ); Break; Case EMediaHardDisk: Abuf. Append (KHard ); Break; Case EMediaCdRom: Abuf. Append (KCDROM ); Break; Case EMediaRam: Abuf. Append (KRam ); Break; Case EMediaFlash: Abuf. Append (KFlash ); Break; Case EMediaRom: Abuf. Append (KRom ); Break; Case EMediaRemote: Abuf. Append (KRemote ); Break; Default: Abuf. Append (KUnknown ); } Abuf. Append (KDriveAtts ); If (di. iDriveAtt & KDriveAttLocal) Abuf. Append (KLocal ); If (di. iDriveAtt & KDriveAttRom) Abuf. Append (KRomDrive ); If (di. iDriveAtt & KDriveAttRedirected) Abuf. Append (KRedirected ); If (di. iDriveAtt & KDriveAttSubsted) Abuf. Append (KSubstituted ); If (di. iDriveAtt & KDriveAttInternal) Abuf. Append (KInternal ); If (di. iDriveAtt & KDriveAttRemovable) Abuf. Append (KRemoveable ); Abuf. Append (KMediaAtts ); If (di. iMediaAtt & KMediaAttVariableSize) Abuf. Append (KDynamic ); If (di. iMediaAtt & KMediaAttDualDensity) Abuf. Append (KDual ); If (di. iMediaAtt & KMediaAttFormattable) Abuf. Append (KFormattable ); If (di. iMediaAtt & KMediaAttWriteProtected) Abuf. Append (KWriteProtected ); Abuf. Append (KnewLine ); Console-> Printf (abuf ); } LOCAL_C void MainL (const TDesC & aArgs) { // // Add your program code here, example code below // // Console-> Write (_ L ("Hello, world! \ N ")); PrintDriveInfo (); Console-> Printf (_ L ("Command line args: \" % S \ "\ n"), & aArgs ); }
|