S60 enable process with Parameters

Source: Internet
Author: User

Recently participated in the project, which used the inter-process communication function in s60. The following describes how to use it:

 

1. Use a command line parameter to start the application with parameters:
// * Start the code and use it when you need to start a program */

// [1] define command line parameters

Capacommandline * cmd = capacommandline: newlc ();

// [2] set the command type

CMD-> setcommandl (eapacommandrun );

// [3] set the name of the application to be started

CMD-> setexecutablenamel (_ L ("helloworld.exe "));

// [4] sets a parameter, which is a file name

CMD-> setdocumentnamel (_ L ("x.txt "));

// [5] sets the parameter, which is a string

CMD-> settailendl (_ L8 ("message tail "));

// [6] start the program

Rapalssession als;

User: leaveiferror (ALS. Connect ());

Cleanupclosepushl (ALS );

User: leaveiferror (ALS. Startapp (* cmd ));

Cleanupstack: popanddestroy (2 );

 

// * Receive parameters in the started application */

// This function is implemented by reloading the ceikappui: processcommandparametersl method in appuik.

 

Tbool chello2appui: processcommandparametersl (tapacommand acommand, tfilename & adocumentname, const tdesc8 & atail)

{

// Receives the parameter line [4] in the startup code

Tfilename file = adocumentname;

// Receives the parameter line [2] in the startup code

Tapacommand COM = acommand;

// Receives the parameter line [5] in the startup code

Hbufc8 * STR = atail. allocl ();

Delete STR;

}

 

 

2. Use startdocument to start the application with parameters:
// * Start the code and use it when you need to start a program */

Rapalssession als;

Tthreadid ID;

Tuid uid;

// Uid of the started Program

UID. iuid = 0xe469529f;

ALS. Connect ();

ALS. startdocument (_ L ("hello2.txt"), uid, ID );

ALS. Close ();

 

Receive parameters of the started program according to parameters in instance 1.

 

3. Use rprocess to start the application with parameters:
// * Start the code and use it when you need to start a program */

Rprocess * process = new rprocess ();

Tuidtype uidtype (knulluid );

Process-> Create (_ L ("// sys/bin // helloworld.exe"), _ L ("teststring"), uidtype );

Process-> resume ();

Process-> close ();

Delete process;

 

// * Receive parameters in the started application */

Rbuf16 Buf;

Buf. Create (50 );

User: CommandLine (BUF); // Buf = "teststring"

Buf. Close ();

 

4. Use tfindprocess to find a started application:
// Process name to be searched

_ Partition (kprocessname, "hello2_0xe469529f *");

// Construct a process search object

Tfindprocess findprocess (kprocessname );

Tfullname processname;

// Start searching for the application and return the result through processname

Findprocess. Next (processname );

If (processname = knulldesc)

{

// The application to be searched is not started

}

5. Send a message to a started application:
Tuid uidapp = tuid: UID (0xe469529f );

Tapatasklist tasklist (ceikonenv: static ()-> wssession ());

Tapatask task = tasklist. findapp (uidapp );

Tbuf <256> ARG;

Arg. append (_ L ("My text "));

Hbufc8 * pbuf;

If (task. exists ())

{

// Send message to the task; uid is not used, but It doesn's work.

Pbuf = hbufc8: newl (Arg. Length ());

Tptr8 PTR = pbuf-> des ();

PTR. Copy (ARG );

Nerr = task. sendmessage (tuid: UID (kuidapamessageswitchcreatefilevalue), * pbuf );

Task. bringtoforeground ();

}

// * Receive parameters in the started application */

// This function is implemented by reloading the ceikappui: processmessagel method in appuik.

 

Void chello2appui: processmessagel (tuid auid, const tdesc8 & aparams)

{

Tuid u = auid;

}

 

The above is a summary of the methods for inter-process communication. Not complete...

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/nie_feilong/archive/2010/01/18/5208892.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.