⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driveinfo.cpp

📁 《基于symbian os的手机开发与应用》
💻 CPP
字号:
// DriveInfo.cpp
//
// Copyright (c) 2005 Neusoft Institute of Information Technology.Chengdu  
// All rights reserved.

// written by hewei
//  
// version 1.0

//Date: 2005-10-31

// This program demostrate how to obtain drive infomation. 

// NOTE: the structure of this example is different to standard E32 examples


#include <e32cons.h>
#include <f32file.h>

  // All messages written to this
LOCAL_D CConsoleBase* console;
LOCAL_D RFs iFs;
// Function prototypes
 void callExampleL();
 void doExampleL();
 void PrintDriveInfo();


//////////////////////////////////////////////////////////////////////////////
//
// Main function called by E32
//
//////////////////////////////////////////////////////////////////////////////
GLDEF_C TInt E32Main()
    {
	  // Get cleanup stack
	CTrapCleanup* cleanup=CTrapCleanup::New();

	 // Some more initialization, then do the example
    TRAPD(error,doExampleL());
	
	  
	  // callExampleL() should never leave.
	_LIT(KMsgPanicEpoc32ex,"EPOC32EX");
	__ASSERT_ALWAYS(!error,User::Panic(KMsgPanicEpoc32ex,error));

  // destroy the cleanup stack
	delete cleanup;
	
	  // return
	return 0;
    }


//////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////
void doExampleL()
{
  	_LIT(KPressAnyKey,"[Press any key...OK]");
	//Get Console;
	_LIT(KMsgExampleCode,"Symbian OS Example Code");
	console = Console::NewL(KMsgExampleCode,TSize(KConsFullScreen,KConsFullScreen));
		// Put console onto the cleanup stack.
	CleanupStack::PushL(console);

	int error;
	TRAP(error,callExampleL());
	//TRAPD(error,callExampleL());
    if(error)
	{
		_LIT(KERROR,"error occured!\n");
		console->Printf(KERROR);
	
	}
	else{
      _LIT(KNOLEAVE,"No Leave!\n");
		console->Printf(KNOLEAVE);
	}
	console->Printf(KPressAnyKey);
	console->Getch();
		// Remove the console object from the cleanupstack
	  // and destroy it. 	
	CleanupStack::PopAndDestroy();
}

void callExampleL() 
    {
  
   User::LeaveIfError(iFs.Connect());//connect to file server
  
   PrintDriveInfo();
//Close file server
   iFs.Close();


}
void PrintDriveInfo()
{
	//Some Infomation
	_LIT(KRETURN,"\n");
	_LIT(KPrompt,"There are drives list below: \n");     
	_LIT(KCHAR,"%c\n");
	_LIT(KDriveInfo,"information about drive:\n");
	_LIT(KIsSystem,"System\n");
	_LIT(KIsArchive,"Archive\n");

	console->Printf(KPrompt);
    TChar DriveLetter;
	TDriveList dList;
	iFs.DriveList(dList);
	for(TInt i=0;i<dList.Length();i++)
		if(dList[i])
		{
			iFs.DriveToChar(i,DriveLetter);
			console->Printf(KCHAR,DriveLetter);
			console->Printf(KRETURN);
		}


}












⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -