Symbian
Symbian OS Library

FAQ-0576 How do I create a Cone environment in *.exe files?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Emulator
Created: 04/02/2001 Modified: 12/11/2001
Number: FAQ-0576
Platform: ER5, Symbian OS v6.0, Symbian OS v6.1

Question:
How do I create a Cone environment in *.exe files?

Answer:
According to the SDK documentation this can be done as follows:

CCoeEnv* coe=new CCoeEnv;
coe->ConstructL();
............................................................
..........example code ....................
............................................................
coe->DestroyEnvironment(); // destroy cone

When you try to build and run this on the target machine everything will work fine. However, under WINS it returns an error code of -1. When you step into the ConstructL() of CCoeEnv you will find that a lot of things are being set up for you such as: active scheduler, a session with the
file server for accessing resource files, a session with the window server, etc. You will also find that the line of code that creates a session with a window server is the one that leaves with an error code of -1.

The solution to this problem is very simple. All you need to do is rebuild this example for the WINS environment to use an EXEDLL (from v5) or EPOCEXE from v6) target type
(there is another Knowledgebase entry explaining how this can be done ). The session with the Window Server will be created, and ConstructL() will finish successfully.

NOTE: Up to version 6.0 there is a defect that stops you creating a further CCoeEnv on the same thread after calling DestroyEnvironment().