VC++, MFC - Extention Dlls
Regular DLLs allow us to use MFC in the exported functions,but they do not require that the calling application should also use MFC. Thus a regular DLL can be easily used in programs developed in other Windows programming languages like Visual Basic or Delphi. A big restriction of regular DLL is that it can't export C++ classes. This restriction has been lifted in an Extension DLL. In an Extension DLL we can export classes. This forces the client application to be an MFC application. The client can construct object of the exported class or derive classes from it. An extension DLL should meet two requirements:
(a) An extension DLL dynamically links to the code in the MFC DLL. Hence an extension DLL requires that the client program be dynamically linked to the MFC library (the AppWizard default).
(b) Both the client program and the extension DLL be synchronized to the same version of the MFC DLLs (mfc42.dll, mfcd42.dll, and so on).
Here we have chosen to create a simple CD Player. As shown in the figure, the texts on the push buttons suggest you can play the current track or switch over to the previous or next track before playing it. You can also provide a button for connecting to the web site www.channelindia.com/ypkanetkar (or any such site) on selecting the bottommost button in the dialog.
Windows recognizes three fundamental multimedia formats:
(a) Wave forms audio
(b) Midi Sequences
Depending upon your programming needs, you can choose one of the three interface levels to interact with the multimedia subsystems in Windows. The high level interface is based on MCIWnd class. The mid-level interface is the Media Control Interface or MCI. MCI provides a device independent command message and command string interface for the playback and recording of audio and visual data. At the lowest level there are several interfaces for waveform audio, video and midi recording and playback.
For our application the MCI interface should suffice. The MCI provides a set of device-independent command message and command strings for controlling multimedia devices. Command strings are sent to devices using the mciSendString( ) function. Command messages are sent to devices using mciSendCommand( ) function. The entire CD player program revolves around the mciSendCommand( ) function.
This application has been created using 'MFC AppWizard (dll)'. The application contains 2 main files 'cdplayer.h' and 'cdplayer.cpp'. The '.h' file contains the declaration of the class written for palying the CD. The '.cpp' contains its implementation. The class declaration contains a macro AFX_EXT_CLASS which tells the linker that the class is available for use by other Visual C++ programs. Building the DLL would generate 2 files: '.dll' and '.lib'. With these 2 files a 'cdplayer.h' file will have to be supplied to the client.
The client that would use this DLL must be created as a new project-a 'Win32 Application'-with a suitable name, say 'client'.