Non-embeddable Applications

Procedure

The TARGETTYPE in the MMP file changes from app to exe. However, for applications that need to also run on the EKA1 emulator, the TARGETTYPE must be exedll. Hence, the following lines should replace the existing TARGET and TARGETTYPE lines:

#if !defined(EKA2) && defined(WINS) 
TARGET ExeAppTest.app 
TARGETTYPE exedll 
deffile \epoc32\release\wins\exedllapp.def 
#else 
TARGET ExeAppTest.exe 
TARGETTYPE exe 
#endif

The TARGET filename's extension should be .exe. It is also important is that the second UID (the application identifier) remains the same: 0x100039CE. For EKA1 emulator builds, the binary produced is a DLL with the entry point exported at ordinal one. Therefore, as in the example above, a deffile statement is used to define the export.

The stack size should be explicitly set to a value greater than the default of 8K. Previously, applications were launched in a process initiated by apprun.exe which had a stack size of 20K. Therefore, to ensure the converted application will not have any problems with stack size, this is the minimum value the stack size should be set to. This is done in the MMP file with the line:

epocstacksize 0x5000

Note that embedding an EXE-app inside another EXE-app (see the Embeddable applications section below) is enough to overflow the default 8K stack.

The API for starting the application framework is in eikcore.dll, so eikcore.lib needs to be listed in the LIBRARY section of the MMP file.

The EikStart::RunApplication() function needs to be called from the EXE's entry point, passing as an argument a pointer-to-function which creates an instance of the CApaApplication -derived class (this is the same function that is exported at ordinal 1 for DLL-apps). In EKA1 emulator builds, the command line also needs to be passed to this function. This is demonstrated by the following code, which works for all builds:

#include <eikstart.h> 
LOCAL_C CApaApplication* NewApplication()
    {
    return new CExampleApplication;
    } 
GLDEF_C TInt E32Main()
    {
    return EikStart::RunApplication(NewApplication);
    }

#if defined(__WINS__) && !defined(EKA2) 
GLDEF_C TInt E32Dll(TDllReason)
    {
    return KErrNone;
    } 
EXPORT_C TInt WinsMain(TDesC* aCmdLine)
    {
    return EikStart::RunApplication(NewApplication, aCmdLine);
    } 
#endif

If the application needs to store configuration or application data, a private directory will need to be created. For more information on private directories, see the documentation on the RFs class.

The relevant functions in the RFs class for private directories are are:

RFs::PrivatePath

gets the private path for a process

RFs::CreatePrivatePath

creates the private directory for a process on the specified drive

RFs::SetSessionToPrivate

sets the session path to point to the private directory on the specified drive

Related concepts