1 // Windows/DLL.h 2 3 #ifndef __WINDOWS_DLL_H 4 #define __WINDOWS_DLL_H 5 6 #include "../Common/MyString.h" 7 8 namespace NWindows { 9 namespace NDLL { 10 11 #ifdef UNDER_CE 12 #define My_GetProcAddress(module, procName) ::GetProcAddressA(module, procName) 13 #else 14 #define My_GetProcAddress(module, procName) ::GetProcAddress(module, procName) 15 #endif 16 17 class CLibrary 18 { 19 HMODULE _module; 20 public: CLibrary()21 CLibrary(): _module(NULL) {}; ~CLibrary()22 ~CLibrary() { Free(); } 23 HMODULE()24 operator HMODULE() const { return _module; } 25 HMODULE* operator&() { return &_module; } IsLoaded()26 bool IsLoaded() const { return (_module != NULL); }; 27 Attach(HMODULE m)28 void Attach(HMODULE m) 29 { 30 Free(); 31 _module = m; 32 } Detach()33 HMODULE Detach() 34 { 35 HMODULE m = _module; 36 _module = NULL; 37 return m; 38 } 39 40 bool Free() throw(); 41 bool LoadEx(CFSTR path, DWORD flags = LOAD_LIBRARY_AS_DATAFILE) throw(); 42 bool Load(CFSTR path) throw(); GetProc(LPCSTR procName)43 FARPROC GetProc(LPCSTR procName) const { return My_GetProcAddress(_module, procName); } 44 }; 45 46 bool MyGetModuleFileName(FString &path); 47 48 FString GetModuleDirPrefix(); 49 50 }} 51 52 #endif 53