Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HandlerLoader.h « Common « UI « 7zip « CPP - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2a87801991fb5e7d418b10ff9e9e325bfe8e2c4f (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
// HandlerLoader.h

#ifndef __HANDLERLOADER_H
#define __HANDLERLOADER_H

#include "../../ICoder.h"
#include "Windows/DLL.h"

typedef UInt32 (WINAPI * CreateObjectFunc)(
    const GUID *clsID, 
    const GUID *interfaceID, 
    void **outObject);

class CHandlerLoader: public NWindows::NDLL::CLibrary
{
public:
  HRESULT CreateHandler(LPCWSTR filepath, REFGUID clsID, 
      void **archive, bool outHandler)
  {
    if (!Load(filepath))
      return GetLastError();
    CreateObjectFunc createObject = (CreateObjectFunc)
        GetProcAddress("CreateObject");
    if (createObject == NULL)
    {
      HRESULT res = ::GetLastError();
      Free();
      return res;
    }
    HRESULT res = createObject(&clsID, 
        outHandler ? &IID_IOutArchive : &IID_IInArchive, (void **)archive);
    if (res != 0)
      Free();
    return res;
  }
};

#endif