×
Namespaces

Variants
Actions

如何获得当前手机安装的所有程序列表

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台: S60, Series 80

文章
翻译:
hoolee
最后由 hamishwillee 在 09 Aug 2012 编辑
  • 详细描述

下列代码可以生成一个文本文件,里面包括了一组程序列表和他们的UID值,它可以在任何Symbian OS手机上运行。


  • 解决方案
#include <f32file.h>    // link against efsrv.lib
#include <apgcli.h> // link against apgrfx.lib, apparc.lib
 
_LIT(KFileName, "c:\\applications.txt");
const TInt KMaxSize = 512;
 
LOCAL_C void WriteAppInfoToFileL()
{
RFs fs;
RFile file;
RApaLsSession lsSession;
 
// Connect to file server
User::LeaveIfError( fs.Connect() );
CleanupClosePushL( fs );
 
// Connect to application architecture server
User::LeaveIfError( lsSession.Connect() );
CleanupClosePushL( lsSession );
 
// Open (replace if exists) the file for writing
file.Replace( fs, KFileName, EFileWrite | EFileStreamText );
CleanupClosePushL( file );
 
TApaAppInfo appInfo;
TBuf<KMaxSize> buf;
TBuf8<KMaxSize> fileBuf;
 
// Get info on all apps, then iterate through each app
// and write its info (caption, name, uid) to file
lsSession.GetAllApps();
while( lsSession.GetNextApp( appInfo ) == KErrNone )
{
buf.Zero();
buf.AppendNum( (TUint)aInfo.iUid.iUid, EHex );
buf.Append( _L("\t") );
buf.Append( appInfo.iCaption );
buf.Append( _L("\t") );
buf.Append( appInfo.iFullName );
fileBuf.Copy( buf );
fileBuf.Append( _L("\n") );
file.Write( fileBuf );
}
 
CleanupStack::PopAndDestroy( 3 ); // file, lsSession, fs
}
This page was last modified on 9 August 2012, at 05:20.
72 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×