Exe with No console window??

Login to reply to this topic.
Tue, 2006-03-21 12:56
Anonymous
Forum posts: 2043
I'm creating an exe like this:

#include <e32base.h>
#include <e32cons.h>

_LIT(KTxtMyExe,"MyExe");
_LIT(KFormatFailed,"failed: leave code=%d");

// public
LOCAL_D CConsoleBase* console; // write all your messages to this

// private
LOCAL_C void callMainL(); // initialize with cleanup stack, then do example

GLDEF_C TInt E32Main() // main function called by E32
    {
   __UHEAP_MARK;
   CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
   TRAPD(error,callMainL()); // more initialization, then do example
   __ASSERT_ALWAYS(!error,User::Panic(KTxtMyExe,error));
   delete cleanup; // destroy clean-up stack
   __UHEAP_MARKEND;
   return 0; // and return
    }

LOCAL_C void callMainL() // initialize and call example code under cleanup stack
    {
   console=Console::NewL(KNullDesC,TSize(KDefaultConsWidth,KDefaultConsHeight));
   CleanupStack::PushL(console);
   console->Getch(); // get and ignore character
   CleanupStack::PopAndDestroy(); // close console
    }



When i try to change the size of console here:
console=Console::NewL(KNullDesC,TSize(KDefaultConsWidth,KDefaultConsHeight));

it gets crash....

What i want is: exe with no console window. Is it possible?

Thanks ahead!

Tue, 2006-03-21 17:39
Joined: 2005-03-04
Forum posts: 176
Re: Exe with No console window??
Then intantiate no console. For the rest (the Windowgroup) try:
Code:
    iWindowGroup = new (ELeave) RWindowGroup(iWsSession);
    iWindowGroup->Construct((TUint32) iWindowGroup, EFalse);
    iWindowGroup->SetOrdinalPosition(-1);
    iWindowGroup->EnableReceiptOfFocus(EFalse);
    iWindowGroupName = CApaWindowGroupName::NewL(iWsSession);
    iWindowGroupName->SetHidden(ETrue);
    iWindowGroupName->SetWindowGroupName(*iWindowGroup);

Now your program will do something without any window...
Was that your intention?

regards;
CG
Tue, 2006-03-21 19:45
Error (not verified)
Forum posts: 2043
Re: Exe with No console window??
Quote from: CG
Then intantiate no console. For the rest (the Windowgroup) try:
Code:
    iWindowGroup = new (ELeave) RWindowGroup(iWsSession);
    iWindowGroup->Construct((TUint32) iWindowGroup, EFalse);
    iWindowGroup->SetOrdinalPosition(-1);
    iWindowGroup->EnableReceiptOfFocus(EFalse);
    iWindowGroupName = CApaWindowGroupName::NewL(iWsSession);
    iWindowGroupName->SetHidden(ETrue);
    iWindowGroupName->SetWindowGroupName(*iWindowGroup);

Now your program will do something without any window...
Was that your intention?

regards;
CG

Tnx for reply CG

Where exactly i need to add this code?
Do i still need this: console=Console::NewL(KNullDesC,TSize(KDefaultConsWidth,KDefaultConsHeight));
What is "iWsSession"?

I want my program to run in bacground , having no visible window and not being shown in task-list.
Wed, 2006-03-22 08:44
Joined: 2004-12-03
Forum posts: 276
Re: Exe with No console window??
If you don't want a console then y are you creating one??...
remove all the code related to CConsoleBase....

And I don't see anything wrong in your code.... What exactly you mean by crash... is it a leave or panic?

Today is a gift by GOD, that's why it is called the present.

Wed, 2006-03-22 11:40
Error (not verified)
Forum posts: 2043
Re: Exe with No console window??
Quote from: dennis_george
If you don't want a console then y are you creating one??...
remove all the code related to CConsoleBase....

And I don't see anything wrong in your code.... What exactly you mean by crash... is it a leave or panic?

i removed all code related to console.... now in emulator i see
blue color screen only. havnt test how it'll be on device.

Thu, 2006-03-23 06:27
Joined: 2004-12-03
Forum posts: 276
Re: Exe with No console window??
In real device you won't see any screen.... it will run in the background....

Today is a gift by GOD, that's why it is called the present.

Thu, 2006-03-23 12:19
Error (not verified)
Forum posts: 2043
Re: Exe with No console window??
Quote from: dennis_george
In real device you won't see any screen.... it will run in the background....

i tested on device and its working fine Smiley

My exe monitors incomming sms, it gets notify when sms receives. but i'm facing a problem when getting messaging body text.
i made an application (.app) before where i was getting messaging text like this:

if (store->HasBodyTextL())
     {
       CRichText* richText = CRichText::NewL(
       iEikonEnv->SystemParaFormatLayerL(),
       iEikonEnv->SystemCharFormatLayerL());
       CleanupStack::PushL(richText);
       store->RestoreBodyTextL(*richText);

       // rich text contains message body text

        CleanupStack::PopAndDestroy(richText);
      }

but this way dont work with .exe . i'm getting following errors:

error C2065: 'iCoeEnv' : undeclared identifier
error C2440: 'static_cast' : cannot convert from 'int' to 'class CEikonEnv *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
error C2227: left of '->SystemParaFormatLayerL' must point to class/struct/union
error C2440: 'static_cast' : cannot convert from 'int' to 'class CEikonEnv *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
error C2227: left of '->SystemCharFormatLayerL' must point to class/struct/union
Error executing cl.exe.


What should i do to fix it? Tongue

I want to monitor MMS&E-mails too in exe, is it good to have all this in one .exe or i should have running different .exe to monitor each type (sms,mms,e-mails) Huh?
Thu, 2006-03-23 13:15
Joined: 2004-12-03
Forum posts: 276
Re: Exe with No console window??
iEikonEnv is part of UI... so you cant use that in exe...

just simple read the message body with the help of client MTM...

check the following e.g.

Code:
iSmsMtm->SwitchCurrentEntryL(aEntryId);

  iSmsMtm->LoadMessageL();     // load the message

  CRichText& body = iSmsMtm->Body();

  TPtrC msg(body.Read(0));

Today is a gift by GOD, that's why it is called the present.

Thu, 2006-03-23 13:18
Joined: 2004-12-03
Forum posts: 276
Re: Exe with No console window??
Quote
I want to monitor MMS&E-mails too in exe, is it good to have all this in one .exe or i should have running different .exe to monitor each type (sms,mms,e-mails) Huh?

I think you can monitor each of them in a single exe... no need to create separate exe for each of them...

Today is a gift by GOD, that's why it is called the present.

Thu, 2006-03-23 13:32
Error (not verified)
Forum posts: 2043
Re: Exe with No console window??
Quote from: dennis_george
Quote
I want to monitor MMS&E-mails too in exe, is it good to have all this in one .exe or i should have running different .exe to monitor each type (sms,mms,e-mails) Huh?

I think you can monitor each of them in a single exe... no need to create separate exe for each of them...

tnx for reaply dennis Smiley
one thing which i'm not understanding is: when sms arrives i can be notified, but how i'll get  notified of e-mail.
As far as i understand u need to fetch them from server??

could u plz guide me?
Fri, 2006-03-31 14:14
Joined: 2006-03-14
Forum posts: 2
Re: Exe with No console window??
Quote from: dennis_george
In real device you won't see any screen.... it will run in the background....

Is there any possible way to avoid this behaviour?
Sat, 2006-09-23 17:10
Joined: 2005-11-18
Forum posts: 71
Re: Exe with No console window??
Hi!


kostas.perifanos

did u solve your problem if no then you can contact me by the forum.

Regards,
JKS
Mon, 2007-07-09 10:18
Joined: 2006-10-05
Forum posts: 80
Re: Exe with No console window??

hello dennis_george,

I have created an exe for receiving SMSs.
But when I try to read the details of the received SMS, I get a KERN-EXEC 3 panic...

I am also using the same code as u have suggested:

iSmsMtm->SwitchCurrentEntryL(aEntryId);

  iSmsMtm->LoadMessageL();     // load the message

  CRichText& body = iSmsMtm->Body();

  TPtrC msg(body.Read(0));

The panic occurs at the first line of code.

Can anyone help out with this???

Mon, 2007-07-09 10:22
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2009
Re: Exe with No console window??

The code in itself is ok. Have you correctly initialized iSmsMtm ?


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Mon, 2007-07-09 10:36
Joined: 2006-10-05
Forum posts: 80
Re: Exe with No console window??


Yes, I have used the same code as in the smssend example in the S60 2nd edition SDK for FP2.

iSmsMtm is initialized as follows after the EMsvServerReady event occurs:

iSmsMtm = STATIC_CAST( CSmsClientMtm*, iMtmRegistry->NewMtmL( KUidMsgTypeSMS ) );

PS: I have already tested this code in a GUI application. I don't know why its not working in an EXE!

Mon, 2007-07-09 10:38
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2009
Re: Exe with No console window??

Yes it does. As far as I can remember, we have used it in a couple of EXEs.


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

  • Login to reply to this topic.