other-licenses/7zstub/src/Windows/DLL.h

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:135065cac067
1 // Windows/DLL.h
2
3 #ifndef __WINDOWS_DLL_H
4 #define __WINDOWS_DLL_H
5
6 #include "../Common/String.h"
7
8 namespace NWindows {
9 namespace NDLL {
10
11 class CLibrary
12 {
13 bool LoadOperations(HMODULE newModule);
14 protected:
15 HMODULE _module;
16 public:
17 operator HMODULE() const { return _module; }
18 HMODULE* operator&() { return &_module; }
19
20 CLibrary():_module(NULL) {};
21 ~CLibrary();
22 void Attach(HMODULE m)
23 {
24 Free();
25 _module = m;
26 }
27 HMODULE Detach()
28 {
29 HMODULE m = _module;
30 _module = NULL;
31 return m;
32 }
33
34 // operator HMODULE() const { return _module; };
35 // bool IsLoaded() const { return (_module != NULL); };
36 bool Free();
37 bool LoadEx(LPCTSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE);
38 bool Load(LPCTSTR fileName);
39 #ifndef _UNICODE
40 bool LoadEx(LPCWSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE);
41 bool Load(LPCWSTR fileName);
42 #endif
43 FARPROC GetProcAddress(LPCSTR procName) const
44 { return ::GetProcAddress(_module, procName); }
45 };
46
47 bool MyGetModuleFileName(HMODULE hModule, CSysString &result);
48 #ifndef _UNICODE
49 bool MyGetModuleFileName(HMODULE hModule, UString &result);
50 #endif
51
52 }}
53
54 #endif

mercurial