Symbian
Symbian OS Library

FAQ-0574 What is an EPOCEXE target type used for?

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



 

Classification: C++ Category: Emulator
Created: 04/02/2001 Modified: 01/16/2004
Number: FAQ-0574
Platform: Symbian OS v6.0, Symbian OS v6.1, Symbian OS v7.0, Symbian OS v7.0s

Question:
What is an EPOCEXE target used for and what are the code changes I need to make in order to compile?

Answer:

The WINS emulator is a single process environment. Navigating through the file system, using the shell for example,
and selecting and clicking on the plain executable file on a target device would start a different process and this is therefore not supported under WINS.
The EPOCEXE target type has been created in order to improve the emulator so that we could have WINS "executables" which are started
from within the emulator by selecting and clicking on them.

EPOCEXE stands for an EPOC executable that can be launched from a shell. With this target type:
1. A dll is built under the WINS environment with a single fixed function exported. This can then be launched from within a shell by double tapping on the file.
2. An exe file is built under all other environments.

An example of an .mmp file:

TARGET HelloWorld.dll
TARGETTYPE epocexe
SOURCEPATH .
TARGETPATH \system\programs
SOURCE HelloWorld2.cpp
USERINCLUDE .
USERINCLUDE ..\CommonFramework
SYSTEMINCLUDE \Epoc32\include
LIBRARY euser.lib

An example of an .cpp file:
.............................................

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

LOCAL_C void callExampleL() // initialize and call example code under cleanup stack
{
console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
CleanupStack::PushL(console);
TRAPD(error,doExampleL()); // perform example function
if (error)
console->Printf(KFormatFailed, error);
else
console->Printf(KTxtOK);
console->Printf(KTxtPressAnyKey);
console->Getch(); // get and ignore character
CleanupStack::PopAndDestroy(); // close console
}

EXPORT_C TInt WinsMain()
{
#if defined(__WINS__)
E32Main();
#endif
return KErrNone;
}

#if defined(__WINS__)
TInt E32Dll(TDllReason)
{
return 0;
}
#endif
.........................................................