00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "CommonFramework.h"
00019
00020 #include <f32file.h>
00021
00022 #include "UsingDLLs.h"
00023
00024 _LIT(KTxtHarry,"Harry");
00025 _LIT(KTxtSally,"Sally");
00026 _LIT(KTxtDr1,"PolymorphicDLL1.DLL");
00027 _LIT(KTxtDr2,"PolymorphicDLL2.DLL");
00028
00029 _LIT(KTxt1,"dynamically linked DLL example \n\n");
00030 _LIT(KTxt2,"checking UID\n");
00031 _LIT(KTxt3,"DLL has incorrect UID... \n");
00032
00033 void UseDllL(const TFileName& aDllName, const TDesC& aName);
00034
00035 LOCAL_C void doExampleL()
00036 {
00037
00038 RFs fs;
00039 User::LeaveIfError(fs.Connect());
00040 console->Printf(KTxt1);
00041
00042 TFileName dll;
00043 dll = KTxtDr1;
00044 UseDllL(dll, KTxtHarry);
00045 dll = KTxtDr2;
00046 UseDllL(dll, KTxtSally);
00047
00048 fs.Close();
00049 }
00050
00051
00052
00053 void UseDllL(const TFileName& aLibraryName, const TDesC& aName)
00054 {
00055
00056 RLibrary library;
00057
00058 User::LeaveIfError(library.Load(aLibraryName));
00059
00060 console->Printf(KTxt2);
00061
00062 if (library.Type()[1] != KMessengerUid)
00063 {
00064 console->Printf(KTxt3);
00065 User::Leave(KErrGeneral);
00066 }
00067
00068 TLibraryFunction entry=library.Lookup(1);
00069
00070 CMessenger* messenger=(CMessenger*) entry();
00071
00072 CleanupStack::PushL(messenger);
00073
00074 messenger->ConstructL(console, aName);
00075
00076 messenger->ShowMessage();
00077
00078 CleanupStack::PopAndDestroy();
00079
00080 library.Close();
00081 }