home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE15 / CPPCLASS / cpp16 / CPPDLL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-29  |  1.1 KB  |  50 lines

  1. #pragma option -xc //Safe exceptions
  2. #pragma option -WD //makes all functions in a DLL exportable
  3. #include <windows.h>
  4. #include <dos.h>
  5. #include <stdio.h>
  6. #include "delevent.h"
  7.  
  8.  
  9. //we use huge so that we can have far vtbls and not export the whole class
  10. class _huge TDLLClass{
  11.   char Buffer[80];
  12.   int InternalValue;
  13.   TEvent FEvent;
  14.  
  15.   virtual void  _pascal SetValue(int Info){InternalValue = Info;}
  16.   virtual int   _pascal GetValue(){return InternalValue;}
  17.   virtual void  _pascal SetEvent(TEvent func){FEvent = func;};
  18.  
  19.  
  20. public:
  21.   TDLLClass():InternalValue(0){FEvent.Code = NULL;};
  22.  //we only export what we deem needed
  23.   virtual void  _pascal ShowThevalue()
  24.   {
  25.      wsprintf(Buffer, "The value %d\nCOM to da Max!!!!",InternalValue);
  26.      MessageBox(NULL,Buffer,"From The C++ DLL",MB_OK);
  27.   }
  28.  
  29.   virtual void  _pascal DoEvent()
  30.   {
  31.       if (FEvent.Code != NULL)
  32.         ((TNotifyEvent)FEvent.Code)((const void *)this,FEvent.Self);
  33.   }
  34. };
  35.  
  36. extern "C" {
  37.  
  38. TDLLClass* pascal _export ConstructClass()
  39. {
  40.   return new TDLLClass;
  41. };
  42.  
  43. void pascal _export DestructClass(TDLLClass *DLLClass)
  44. {
  45.   if (DLLClass != NULL)
  46.          delete DLLClass;
  47. };
  48. }
  49.  
  50.