| ID | CS001009 | Creation date | June 6, 2008 |
| Platform | S60 3rd Edition, MR | Tested on devices | Nokia N95 |
| Category | Symbian C++ | Subcategory | Code Examples |
| Keywords (APIs, classes, methods, functions): RLibrary |
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.
The following capabilities and libraries are required:
CAPABILITY None
LIBRARY euser.lib
Your DLL header
class MMyDll
{
public:
virtual TInt Data() = 0;
};
class CMyDll : public MMyDll
{
public:
IMPORT_C static MMyDll* NewL();
virtual TInt Data();
};
DLL source
EXPORT_C MMyDll* CMyDll::NewL()
{
return new CMyDll();
}
TInt CMyDll::Data()
{
return 1;
}
#include <e32std.h>
RLibrary library;
// Load dll
User::LeaveIfError(library.Load(_L("CMyDll")));
// Find exported function
TLibraryFunction NewL=library.Lookup(1);
MMyDll* mydll=(MMyDll*) NewL();
// Close the library
library.Close();
TInt value = mydll->Data();
delete mydll;
The DLL is loaded dynamically.
No related wiki articles found