Click here to Skip to main content
13,832,534 members
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 29 Aug 2002
Licenced CPOL

Writing Polymorphic DLL on Symbian platform

, 12 Aug 2003
Rate this:
Please Sign up or sign in to vote.
This article demonstrates how to write polymorphic DLL on Symbian.


  • Knowledge of C++ and COM.
  • Knowledge of Symbian Programming idioms


Writing a polymorphic DLL involves the following steps:

  1. Design and write interfaces.
  2. Implement the interface.

Lets explore these in more detail:

Design and write interface consisting of method declarations.

An interface is essentially an abstract class. An example would clarify it:

class ICalculator {

virtual TInt Sum(TInt, TInt) = 0;


Above snippet declares a class ICalculator with one method Sum which would take 2 TInt parameters and would return a TInt value. Take a look at the name given to the class. This is done to follow a convention i.e. an interface name should start with an 'I'. Now if one wishes to implement interface ICalculator, he/she has to implement the method Sum.

COM programmers would be wondering that how it can be an interface without a UUID or something like that. Yes! in Symbian too, an interface requires a UUID. While writing an interface this is how UUID is given to it.

static const TUid KCalculator_DLLUID = {0x100039CE};
static const TUid KCalculator_DLLUID_Ver1 = {0x0352D96B};
class ICalculator {

virtual TInt Sum(TInt, TInt) = 0;


Your polymorphic interface is ready. You have to write it in a .h file so that it can be implemented in other .cpp files.

Implement the interface.

Writing a polymorphic DLL is half done when interface declaration is done. Now one would require to implement it. Implementing an interface is as simple as inheriting abstract classes. You have to inherit from an interface and implement pure virtual methods of the interface.

Again an example would help us understand this:

class CImpCalculator: public ICalculator {


EXPORT_C CImpCalculator* NewImpClass();

//function would be exposed through Function table
TInt Sum(TInt num1,TInt num2);

GLDEF_C TInt E32Dll(TDllReason) {

return KErrNone;

EXPORT_C CImpCalculator* CImpCalculator::NewImpClass() {

return new (ELeave) CImpCalculator;

TInt CImpCalculator::Sum(TInt num1,TInt num2) {

return num1 + num2;


The example above does something more than just implementing the interface. The class CImpCalculator has a method of its own, NewImpClass. This method has a qualifier EXPORT_C. Clearly this is the method which is exposed from the implementation class. In Symbian it is not required to export or expose all the methods from an interface. Only method which needs to be exposed is which returns the object of the interface (or should I say the implementor class?). Rest of the methods can be accessed from function table. The NewImpClass method returns a pointer to the newly created object.

E32Dll method has to be written in every Polymorohic DLL as it is required by the Symbian run time. You would get linking errors in case you forget to write it. This method is responsible to allocate thread local store for the DLL instance.

Now you are ready to compile and build your own DLL. Build it and start using it.

Lastly these DLLs are called polymorphic because one can write many implementations of the same interface. Further all the Symbian GUI applications are Polymorphic DLLs. Check the GUI SDK examples, you will find E32Dll method implemented.

That's all you would require to write a DLL on Symbian!! Note that I have tested the code on NOKIA Series 60 emulator.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Amit Arvind Limaye
Web Developer
India India
Amit Limaye has 5+ years experience in Symbian and Window CE programming for the Pocket PC and SmartPhone 2002 platform using eVC++ and ATL COM. Currently Working in the area of Motirola Power PC and QNX platform.

You may also be interested in...

Comments and Discussions

GeneralMore Information. Pin
Prakash Nadar22-May-05 17:32
memberPrakash Nadar22-May-05 17:32 
General.prt for a new protocol Pin
Member 113345927-Apr-05 1:37
memberMember 113345927-Apr-05 1:37 
GeneralDma Test on Symbian 8.1b Platform Pin
apphia10-Feb-05 19:21
memberapphia10-Feb-05 19:21 
GeneralCrash Pin
joelparker17-May-04 12:21
memberjoelparker17-May-04 12:21 
GeneralSymbian C++ for 7650 Pin
Rahul Kumar29-May-03 3:42
memberRahul Kumar29-May-03 3:42 
GeneralRe: Symbian java for 6600 Pin
Anonymous17-Jan-05 0:25
memberAnonymous17-Jan-05 0:25 
Generalzip utility for the Symbian Pin
keen1-Jan-03 2:11
memberkeen1-Jan-03 2:11 
GeneralRe: zip utility for the Symbian Pin
Amit Arvind Limaye2-Jan-03 18:39
memberAmit Arvind Limaye2-Jan-03 18:39 
GeneralRe: zip utility for the Symbian Pin
keen3-Jan-03 1:46
memberkeen3-Jan-03 1:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190114.1 | Last Updated 13 Aug 2003
Article Copyright 2002 by Amit Arvind Limaye
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid