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