Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 13:19, 31 December 2007.

Tasks (running GUI application), how to find them

From Forum Nokia Wiki

Following GetTasksL()-function illustrates how to get all running GUI application and their information. Note that if you are running this inside a application that is not implementing standard application framework, you have the replace the RWsSession handling.

If you are interested on finding other than GUI tasks, you could utilize the process finding example code better.


void GetTasksL(void)
{
	RWsSession& wsSession = CEikonEnv::Static()->WsSession();
	
	CApaWindowGroupName* wgName=CApaWindowGroupName::NewL(wsSession);
	CleanupStack::PushL(wgName);
	
	CArrayFixFlat<TInt>* WindowGroupIds = new(ELeave)CArrayFixFlat<TInt>(1);
	CleanupStack::PushL(WindowGroupIds);
 
	User::LeaveIfError(wsSession.WindowGroupList(0,WindowGroupIds));
	const TInt count = WindowGroupIds->Count();
 
	for (TInt ii=0; ii<count; ii++)
	{
		TInt wgId = WindowGroupIds->At(ii);
		wgName->ConstructFromWgIdL(wgId);
 
		//wgName->Caption()
		//wgName->AppUid().Name()
		//wgName->Hidden()
		//wgName->IsSystem()
		//wgName->IsBusy()
		//wgName->AppUid()
		
	}
 
	CleanupStack::PopAndDestroy(2);//WindowGroupIds, wgName
}



Then if you are insteredted to find just one specific task, and you know the application UID you could also use the code shown in the following example function:


void DoSomethingWithTaskL(TUid aUid)
{
	RWsSession& wsSession = CEikonEnv::Static()->WsSession();
	
	TApaTaskList taskList( wsSession );
	TApaTask task = taskList.FindApp(aUid);
 
	if( task.Exists() ) 
	{
		task.EndTask();
		//task.KillTask();
		//task.SendSystemEvent(EApaSystemEventShutdown);
		//task.BringToForeground();
		//task.SendToBackground();
		
		//RThread th;
		//if (t.Open(task.ThreadId())==KErrNone) 
		//{
		//	th.Kill(0);
		//	th.Close();
		//}
	}
}



The DoSomethingWithTaskL() example function shows different approaches you could use for closing GUI application from other processes, note that in S60 3rd Edition some of the ways might require some capabilities. Also the nicest way is always to ask nicely, thus the EndTask() should nearly always be used, it basically sends the exit command to the application, so the application to be closed can handle its data saving etc. when exiting.


Finding an application by its UID ( 3rd Edition )

//  Constant the UID of the application that we are trying to find. 
const TUid KMyAppUid = {0x10009e9f};
 
// Gets a reference to a window server session
TApaTaskList taskList(CCoeEnv::Static()->WsSession());
 
// Create TApaTask instance
TApaTask task = taskList.FindApp(KMyAppUid);
if (task.Exists())
    {
      // Do Something
      
    }




Internal links

Related Discussions
Thread Thread Starter Forum Replies Last Post
How to write a daemon or system service application? quoctuan General Symbian C++ 1 2003-07-02 04:20
Writing into a Word file from GUI application Ruchika General Symbian C++ 0 2003-10-28 08:42
How to create GUI with pys60? yanhua Python 5 2007-09-28 19:32
get aCustomMessage of ActivateLocalViewL dakosurf Symbian User Interface 5 2008-05-05 13:03
EXE (Server) / APP (Gui) design and IPC question blackpaw General Symbian C++ 3 2008-03-14 05:34
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX