Friday, July 20, 2007

How to get Names of all installed applications

The following code sample shows how to get an array containing names of the installed applications.

CDesCArray* GetInstallAppListL(void)
{
CDesCArrayFlat* appArray = new(ELeave)CDesCArrayFlat(10);
CleanupStack::PushL(appArray);

RApaLsSession apaSession;
TRAPD(err, apaSession.Connect());

if(err != KErrNone)
{
CleanupStack::Pop(appArray);
return NULL;
}

CleanupClosePushL(apaSession);

TRAPD(errn, apaSession.GetAllApps());

if(err != KErrNone)
{
CleanupStack::Pop(appArray);
CleanupStack::PopAndDestroy(apaSession);
return NULL;
}

TInt errno(KErrNone);
TApaAppInfo appInfo;

do
{
errno = apaSession.GetNextApp(appInfo);
if(KErrNone == errno && appInfo.iCaption.Length())
{
appArray->AppendL(appInfo.iCaption);
}

}while(KErrNone == errno);

CleanupStack::PopAndDestroy(apaSession);

CleanupStack::Pop(appArray);
return appArray;
}

No comments:

stats counter