Revision as of 09:17, 13 June 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Loading DLL by RLibrary

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Tested with
Devices(s): Nokia N95
Platform(s): S60 3rd Edition, MR
S60 3rd Edition FP1
Keywords: RLibrary
Created: tepaa (28 May 2008)
Last edited: hamishwillee (13 Jun 2012)



This code snippet shows how to load a polymorphic DLL dynamically.

A static DLL is automatically loaded in the RAM when a program that uses it is started. It is also automatically unloaded when it is not needed anymore.

A polymorphic DLL is loaded by calling RLibrary::Load() and unloaded using RLibrary::Close(). Several polymorphic DLLs can show the same interface to their clients. This kind of DLLs are generally used by a framework to provide plug-in features.

MMP file

The following capabilities and libraries are required:

LIBRARY euser.lib

Polymorphic DLL

  • UID2 must be 0x1000008d in DLL's MMP file.
  • DLL must have equal or greater CAPABILITIES than the loading process. Once loaded, DLL runs at the capability level of the loading process. Therefore, a DLL must have all capabilities required by all its client executables, even if the code within the DLL itself does not require some of these capabilities.
  • Define VIRTUAL INTERFACE class that the polymorphic DLLs will implement
  • DLL should have one EXPORTED static function that returns an instance of the interface's class.

Your DLL header

class MMyDll
virtual TInt Data() = 0;
class CMyDll : public MMyDll
IMPORT_C static MMyDll* NewL();
virtual TInt Data();

DLL source

EXPORT_C MMyDll* CMyDll::NewL()
return new CMyDll();
TInt CMyDll::Data()
return 1;

Loading DLL dynamically

#include <e32std.h>
RLibrary library;
// Load dll
// Find exported function
TLibraryFunction NewL=library.Lookup(1);
MMyDll* mydll=(MMyDll*) NewL();
// Close the library
TInt value = mydll->Data();
delete mydll;


The DLL is loaded dynamically.

This page was last modified on 13 June 2012, at 09:17.
59 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.