home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / hpp.z / WMODULE.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-27  |  3.2 KB  |  118 lines

  1. /**********************************************************************
  2.  * 
  3.  * WModule
  4.  *
  5.  *     A wrapper class for handling modules (EXE and DLL handles).
  6.  *     Unlike other classes, no reference counting is done.  You
  7.  *     must explicitly load and unload DLLs.  This is done so that
  8.  *     you don't accidentally unload a DLL when you don't want to.
  9.  *
  10.  *********************************************************************/
  11.  
  12. #ifndef _WMODULE_HPP_INCLUDED
  13. #define _WMODULE_HPP_INCLUDED
  14.  
  15. #ifndef _WNO_PRAGMA_PUSH
  16. #pragma pack(push,4);
  17. #pragma enum int;
  18. #endif
  19.  
  20. #ifndef _WOBJECT_HPP_INCLUDED
  21. #  include "wobject.hpp"
  22. #endif
  23. #ifndef _WSTRING_HPP_INCLUDED
  24. #  include "wstring.hpp"
  25. #endif
  26.  
  27. class WBuffer;
  28.  
  29. class WCMCLASS WModule : public WObject {
  30.     WDeclareSubclass( WModule, WObject )
  31.  
  32.     public:
  33.  
  34.         /****************************************************************
  35.          * Constructors/destructors
  36.          ****************************************************************/
  37.  
  38.         // See the Load methods below...
  39.  
  40.         WModule();
  41.         WModule( const WModuleHandle handle );
  42.         WModule( const WModule & copy );
  43.  
  44.         ~WModule();
  45.  
  46.         /****************************************************************
  47.          * Properties
  48.          ****************************************************************/
  49.  
  50.         // Name 
  51.         //
  52.         //    Returns the full path of the module. 
  53.  
  54.         WString GetName() const;
  55.  
  56.         // Handle
  57.         //
  58.         //    The system handle for the module.
  59.  
  60.         WModuleHandle GetHandle() const { return _module; }
  61.  
  62.         /****************************************************************
  63.          * Methods
  64.          ****************************************************************/
  65.  
  66.         // FindProcedure
  67.         //
  68.         //    Return the address of an exported procedure.
  69.  
  70.         void *FindProcedure( const WChar *name ) const;
  71.  
  72.         // Load
  73.         //
  74.         //    Load a DLL by the given name, or attach to an already
  75.         //    loaded DLL.
  76.  
  77.         WBool Load( const WChar *path=NULL );
  78.         WBool Load( const WModuleHandle handle );
  79.         WBool Load( const WModule & copy );
  80.  
  81.         // LoadResourceData
  82.         //
  83.         //    Load the data for a resource and store it in the
  84.         //    give WBuffer.  Returns TRUE if the resource was
  85.         //    found and loaded.
  86.  
  87.         WBool LoadResourceData( const WResourceID & id, WBuffer *buf ) const;
  88.  
  89.         // Unload
  90.         //
  91.         //    Unload the DLL.
  92.  
  93.         WBool Unload();
  94.  
  95.         /****************************************************************
  96.          * Operators
  97.          ****************************************************************/
  98.  
  99.         WModule& operator=( const WModule & copy );
  100.         WModule& operator=( const WModuleHandle & handle );
  101.  
  102.         int operator==( const WModule & other );
  103.  
  104.         int operator!=( const WModule & other );
  105.  
  106.         operator WModuleHandle() const { return _module; }
  107.  
  108.     private:
  109.         WModuleHandle _module;
  110. };
  111.  
  112. #ifndef _WNO_PRAGMA_PUSH
  113. #pragma enum pop;
  114. #pragma pack(pop);
  115. #endif
  116.  
  117. #endif // _WMODULE_HPP_INCLUDED
  118.