michael@0: // Windows/DLL.h michael@0: michael@0: #ifndef __WINDOWS_DLL_H michael@0: #define __WINDOWS_DLL_H michael@0: michael@0: #include "../Common/String.h" michael@0: michael@0: namespace NWindows { michael@0: namespace NDLL { michael@0: michael@0: class CLibrary michael@0: { michael@0: bool LoadOperations(HMODULE newModule); michael@0: protected: michael@0: HMODULE _module; michael@0: public: michael@0: operator HMODULE() const { return _module; } michael@0: HMODULE* operator&() { return &_module; } michael@0: michael@0: CLibrary():_module(NULL) {}; michael@0: ~CLibrary(); michael@0: void Attach(HMODULE m) michael@0: { michael@0: Free(); michael@0: _module = m; michael@0: } michael@0: HMODULE Detach() michael@0: { michael@0: HMODULE m = _module; michael@0: _module = NULL; michael@0: return m; michael@0: } michael@0: michael@0: // operator HMODULE() const { return _module; }; michael@0: // bool IsLoaded() const { return (_module != NULL); }; michael@0: bool Free(); michael@0: bool LoadEx(LPCTSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE); michael@0: bool Load(LPCTSTR fileName); michael@0: #ifndef _UNICODE michael@0: bool LoadEx(LPCWSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE); michael@0: bool Load(LPCWSTR fileName); michael@0: #endif michael@0: FARPROC GetProcAddress(LPCSTR procName) const michael@0: { return ::GetProcAddress(_module, procName); } michael@0: }; michael@0: michael@0: bool MyGetModuleFileName(HMODULE hModule, CSysString &result); michael@0: #ifndef _UNICODE michael@0: bool MyGetModuleFileName(HMODULE hModule, UString &result); michael@0: #endif michael@0: michael@0: }} michael@0: michael@0: #endif