In the below sample, only the interface ISkypeClientLib is being exported.
// This interface is exported from the DLL
1: class SKYPECLIENTLIB_API ISkypeClientLib
2: {
3: public:
4: virtual bool Connect(char* strAccountUID,char* strAccountPWD) = 0;
5: virtual void LogOut() = 0;
6: };
7:
8: // Forward declaration
9: class CSkype;
10:
11: class CSkypeClientLib: public ISkypeClientLib
12: {
13: public:
14: CSkypeClientLib(void);
15: virtual bool Connect(char* strAccountUID,char* strAccountPWD);
16: virtual void LogOut();
17:
18: private :
19: CSkype *pSkype ;
20: // more code
21:
22: }
23:
The derived class CSkypeClientLib has the implementations for the functions, but is hidden from the user.
In the main application the user calls the function GetSkypeLibrary( ) , which returns a CSkypeClientLib pointer to the user.
1: SKYPECLIENTLIB_API ISkypeClientLib* GetSkypeLibrary(void)
2: {
3: ISkypeClientLib *pSkypeLib = new CSkypeClientLib();
4: return pSkypeLib;
5: }
The user can now use the pointer to call the respective functions.
One can further extend the functionality by doing the following
1: if(riid == __uuidof(CSkypeClientLib))
2: return new CSkypeClientLib;
No comments :
Post a Comment