×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    How to pass argument in console EXE function?

    Hi

    I am doing work in symbian s60 3rd edition.

    I want to call OpenC console EXE application from 3rd edition Symbian application.

    Console Exe have following funtion which have a two arguments.
    int main(int argc, char **argv)

    I want to call this function from symbian 3rd edition, anybody knows that how to do that?

    I know that symbian console exe call in following way.
    Code:
    	_LIT(KExecutableName, "myopenc.exe");
    					
    	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
    	cmdLine->SetCommandL(EApaCommandRun);
    	cmdLine->SetExecutableNameL(KExecutableName);
    	RApaLsSession apals;
    	User::LeaveIfError(apals.Connect());
    	CleanupClosePushL(apals);
    	User::LeaveIfError(apals.StartApp(*cmdLine));
    	CleanupStack::PopAndDestroy(); 
    	CleanupStack::PopAndDestroy(cmdLine);
    Regards,
    SymbianTH

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,335

    Re: How to pass argument in console EXE function?

    Try SetTailEndL from CApaCommandLine.
    Nokia Developer Wiki Moderation team

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,567

    Re: How to pass argument in console EXE function?

    You can try the RProcess::Create-approach too, it also supports an "aCommand" argument.
    Note that in both cases it may happen that you do not get anything in argc/v, in that case check User::CommandLine/Length.

  4. #4
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: How to pass argument in console EXE function?

    Quote Originally Posted by wizard_hu_ View Post
    You can try the RProcess::Create-approach too, it also supports an "aCommand" argument.
    Note that in both cases it may happen that you do not get anything in argc/v, in that case check User::CommandLine/Length.
    Yes Wizard_hu

    Exactly you are right in following both case I am do not get proper arguments

    Code:
    	_LIT(KExecutableName, "ffmpeg.exe");
    	_LIT8(KParameters, "-y -i Movie2_Personal1.mpg -s qcif -sameq -acodec libfaac -ac 1 -ar 8000 -ab 32 destination.3gp");
    
    
    1st Case
    =========	
    	RProcess process;
    	CleanupClosePushL(process);
    	User::LeaveIfError(process.Create(_L("ffmpeg.exe"), _L("-y -i Movie2_Personal1.mpg -s qcif -sameq -acodec libfaac -ac 1 -ar 8000 -ab 32 destination.3gp")));
    	process.Resume();
    	CleanupStack::PopAndDestroy();
    
    
    2nd Case
    =========
    	
    	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
    	cmdLine->SetCommandL(EApaCommandRun);
    	cmdLine->SetExecutableNameL(KExecutableName);
    	cmdLine->SetTailEndL(KParameters);
    	RApaLsSession apals;
    	User::LeaveIfError(apals.Connect());
    	CleanupClosePushL(apals);
    	User::LeaveIfError(apals.StartApp(*cmdLine));
    	CleanupStack::PopAndDestroy(); 
    	CleanupStack::PopAndDestroy(cmdLine);
    FFMPEG.EXE
    Code:
    FFMPEG.C
    --------
    int main(int argc, char **argv)
    {	
        int i;
        int64_t ti;
        int err; 
        
        avcodec_register_all();
        avdevice_register_all();
        av_register_all();
    .
    .
    }

    Where I can check User::CommandLine in symbian application or in OpenC application?
    If possible than please tell me how to check User::CommandLine?

    Regards,
    SymbianTH
    Last edited by SymbianTH; 2009-10-01 at 14:27. Reason: Add Extra Code

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,335

    Re: How to pass argument in console EXE function?

    Quote Originally Posted by SymbianTH View Post
    Exactly you are right in following both case I am do not get proper arguments
    It works apparently fine. This is what I do:

    Code:
    *) From sender side: S60 GUI application. 
    _LIT(KEngineName,"OpenCTest.exe");
    _LIT(KMyExeFileCmd,"first second third");
    TRequestStatus status;    
    RProcess process;     
    User::LeaveIfError(process.Create(KEngineName, KMyExeFileCmd));    
    process.Logon(status);    
    process.Resume();     
    User::WaitForRequest(status); // wait until the engine process finishes    process.Close();
    Code:
    *) On receiving OpenC side:
    int main(int argc, char* argv[])
    {
    	printf("No. of arg = %d\n",argc);
    	printf("First is = %s\n", argv[0]);
             printf("Second is = %s\n", argv[1]);
    	printf("Hello Open C!\n");
    	printf("Press a character to exit!");
    	int c = getchar();
    	return 0;
    }
    You can debug this on emulator and it will give you desired results.

    PS: Just to show, I used RProcess code from Wiki so it might not be an optimized one. You can do that later if it works for you now.
    Last edited by kiran10182; 2009-10-01 at 15:18.
    Nokia Developer Wiki Moderation team

  6. #6
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: How to pass argument in console EXE function?

    Hi


    Thanks kiran now i have done. Actually I done close process after start so that time I don't able to pass argument.

    Now as per your way I have done this.

    Thanks
    SymbianTH

  7. #7
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: How to pass argument in console EXE function?

    Hi

    I want to test console application with two arguments using TRK debugging application.
    but when i write following way under argument Tab than not able to receive any argument.

    -y -i C:\\Data\\Videos\\Test.ogg -vn -acodec libfaac C:\\Data\\Videos\\Test.aac

    Code
    =====
    int main (int argc, char **argv)
    {
    char g;
    printf("Hello OpenC\n");
    printf("No. of arg = %d\n",argc);
    printf("First is = %s\n", argv[0]);
    printf("First is = %s\n", argv[1]);
    printf("First is = %s\n", argv[2]);

    g = getchar();
    }

    anybody knows that how to pass argument in console application using TRK debugging?

    Regards,
    SymbianTH
    Attached Images Attached Images
    Last edited by SymbianTH; 2009-10-21 at 09:42. Reason: attach screenshot.jpg

  8. #8
    Registered User
    Join Date
    Sep 2013
    Posts
    24

    Re: How to pass argument in console EXE function?

    Quote Originally Posted by kiran10182 View Post
    It works apparently fine. This is what I do:

    Code:
    *) From sender side: S60 GUI application. 
    _LIT(KEngineName,"OpenCTest.exe");
    _LIT(KMyExeFileCmd,"first second third");
    TRequestStatus status;    
    RProcess process;     
    User::LeaveIfError(process.Create(KEngineName, KMyExeFileCmd));    
    process.Logon(status);    
    process.Resume();     
    User::WaitForRequest(status); // wait until the engine process finishes    process.Close();
    Code:
    *) On receiving OpenC side:
    int main(int argc, char* argv[])
    {
    	printf("No. of arg = %d\n",argc);
    	printf("First is = %s\n", argv[0]);
             printf("Second is = %s\n", argv[1]);
    	printf("Hello Open C!\n");
    	printf("Press a character to exit!");
    	int c = getchar();
    	return 0;
    }
    You can debug this on emulator and it will give you desired results.

    PS: Just to show, I used RProcess code from Wiki so it might not be an optimized one. You can do that later if it works for you now.

    I tried Same way and also write above same code but not able to execute from GUI, GUI application give me panic -1 (Unable to find the specified object ).

  9. #9
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: How to pass argument in console EXE function?

    that means that your filename is likely wrong.

  10. #10
    Registered User
    Join Date
    Sep 2013
    Posts
    24

    Re: How to pass argument in console EXE function?

    Hi

    Thank you for solving my issue, actually i am fresher in symbian and I do very silly mistake EXE build in FP2 and GUI Run on FP1.

  11. #11
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: How to pass argument in console EXE function?

    no problem, making mistakes is usually the best way on learning. Good to hear that you got it working now.

Similar Threads

  1. Can i Create an edittor in Console Exe!
    By manish.agarw in forum Symbian C++
    Replies: 6
    Last Post: 2009-08-19, 04:23
  2. running a console exe after install
    By davidbr4 in forum Symbian C++
    Replies: 8
    Last Post: 2008-06-09, 16:22
  3. Why console exe program can't be install?
    By ncljh in forum Symbian C++
    Replies: 9
    Last Post: 2008-03-19, 04:47
  4. How to pass HBufC as an argument to a function?
    By ashbhatia in forum Symbian User Interface
    Replies: 6
    Last Post: 2003-03-31, 10:32
  5. D211 with RH7.3
    By fiveam in forum Multimodecards
    Replies: 3
    Last Post: 2003-02-24, 09:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •