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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // Windows/DLL.h
     3 #ifndef __WINDOWS_DLL_H
     4 #define __WINDOWS_DLL_H
     6 #include "../Common/String.h"
     8 namespace NWindows {
     9 namespace NDLL {
    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; }
    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   }
    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 };
    47 bool MyGetModuleFileName(HMODULE hModule, CSysString &result);
    48 #ifndef _UNICODE
    49 bool MyGetModuleFileName(HMODULE hModule, UString &result);
    50 #endif
    52 }}
    54 #endif

mercurial