home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
hpp.z
/
WMODULE.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-18
|
3KB
|
119 lines
/**********************************************************************
*
* WModule
*
* A wrapper class for handling modules (EXE and DLL handles).
* Unlike other classes, no reference counting is done. You
* must explicitly load and unload DLLs. This is done so that
* you don't accidentally unload a DLL when you don't want to.
*
*********************************************************************/
#ifndef _WMODULE_HPP_INCLUDED
#define _WMODULE_HPP_INCLUDED
#ifndef _WNO_PRAGMA_PUSH
#pragma pack(push,8);
#pragma enum int;
#endif
#ifndef _WOBJECT_HPP_INCLUDED
# include "wobject.hpp"
#endif
#ifndef _WSTRING_HPP_INCLUDED
# include "wstring.hpp"
#endif
class WBuffer;
class WCMCLASS WModule : public WObject {
WDeclareSubclass( WModule, WObject )
public:
/****************************************************************
* Constructors/destructors
****************************************************************/
// See the Load methods below...
WModule();
WModule( const WModuleHandle handle );
WModule( const WModule & copy );
~WModule();
/****************************************************************
* Properties
****************************************************************/
// Name
//
// Returns the full path of the module.
WString GetName() const;
// Handle
//
// The system handle for the module.
WModuleHandle GetHandle() const { return _module; }
/****************************************************************
* Methods
****************************************************************/
// FindProcedure
//
// Return the address of an exported procedure.
void *FindProcedure( const WChar *name ) const;
// Load
//
// Load a DLL by the given name, or attach to an already
// loaded DLL.
WBool Load( const WChar *path=NULL,
WBool loadLibraryAsDataOnly=FALSE );
WBool Load( const WModuleHandle handle );
WBool Load( const WModule & copy );
// LoadResourceData
//
// Load the data for a resource and store it in the
// give WBuffer. Returns TRUE if the resource was
// found and loaded.
WBool LoadResourceData( const WResourceID & id, WBuffer *buf ) const;
// Unload
//
// Unload the DLL.
WBool Unload();
/****************************************************************
* Operators
****************************************************************/
WModule& operator=( const WModule & copy );
WModule& operator=( const WModuleHandle & handle );
int operator==( const WModule & other );
int operator!=( const WModule & other );
operator WModuleHandle() const { return _module; }
private:
WModuleHandle _module;
};
#ifndef _WNO_PRAGMA_PUSH
#pragma enum pop;
#pragma pack(pop);
#endif
#endif // _WMODULE_HPP_INCLUDED