home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iprocadr.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  3.6 KB  |  120 lines

  1. #ifndef _IPROCADR_
  2. #define _IPROCADR_
  3. /*******************************************************************************
  4. * FILE NAME: iprocadr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IProcedureAddress                                                        *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #include <ibase.hpp>
  19. #include <ireslib.hpp>
  20.  
  21. class IProcedureAddressData;
  22.  
  23. #pragma pack(4)
  24.  
  25.  
  26. template < class PtrToFnType >
  27. class IProcedureAddress : public IBase {
  28. typedef IBase
  29.   Inherited;
  30. public:
  31. /*------------------------------- Constructors -------------------------------*/
  32.   IProcedureAddress ( const char*          entryPoint,
  33.                       const char*          dllName )
  34.     : dll           ( new IDynamicLinkLibrary( dllName ) ),
  35.       isOrdinal     ( false ),
  36.       name          ( entryPoint ),
  37.       pProcAddrData ( 0 )
  38.   {
  39.     fnPtr = PtrToFnType( this->dll->procAddress( entryPoint ) );
  40.   }
  41.  
  42.   IProcedureAddress ( const char*          entryPoint,
  43.                       IDynamicLinkLibrary& aDLL )
  44.     : dll           ( new IDynamicLinkLibrary( aDLL ) ),
  45.       isOrdinal     ( false ),
  46.       name          ( entryPoint ),
  47.       pProcAddrData ( 0 )
  48.   {
  49.     fnPtr = PtrToFnType( this->dll->procAddress( entryPoint ) );
  50.   }
  51.  
  52.   IProcedureAddress ( unsigned long        ordinal,
  53.                       const char*          dllName )
  54.     : dll           ( new IDynamicLinkLibrary( dllName ) ),
  55.       isOrdinal     ( true ),
  56.       ord           ( ordinal ),
  57.       pProcAddrData ( 0 )
  58.   {
  59.     fnPtr = PtrToFnType( this->dll->procAddress( ordinal ) );
  60.   }
  61.  
  62.   IProcedureAddress ( unsigned long        ordinal,
  63.                       IDynamicLinkLibrary& aDLL )
  64.     : dll           ( new IDynamicLinkLibrary( aDLL ) ),
  65.       isOrdinal     ( true ),
  66.       ord           ( ordinal ),
  67.       pProcAddrData ( 0 )
  68.   {
  69.     fnPtr = PtrToFnType( this->dll->procAddress( ordinal ) );
  70.   }
  71.  
  72.   ~IProcedureAddress ( )
  73.   {
  74.     delete dll;
  75.   }
  76.  
  77. /*--------------------------- Pointers to Functions --------------------------*/
  78.   operator PtrToFnType ( ) const
  79.   {
  80.     return fnPtr;
  81.   }
  82.  
  83. /*------------------------------- Memory Model -------------------------------*/
  84. Boolean
  85.   is32Bit ( ) const
  86.   {
  87.     if ( isOrdinal )
  88.       return dll->isEntryPoint32Bit( ord );
  89.     else
  90.       return dll->isEntryPoint32Bit( name );
  91.   }
  92.  
  93. private:
  94. /*-------------------------------- Private -----------------------------------*/
  95. PtrToFnType
  96.  fnPtr;
  97.  
  98. IDynamicLinkLibrary
  99.  *dll;
  100.  
  101. Boolean
  102.  isOrdinal;
  103.  
  104. union {
  105.   unsigned long
  106.     ord;
  107.   const char
  108.    *name;
  109. };
  110.  
  111. IProcedureAddressData
  112.  *pProcAddrData;
  113.  
  114. }; // IProcedureAddress
  115.  
  116.  
  117. #pragma pack()
  118.  
  119. #endif // _IPROCADR_
  120.