dllexports.cpp

来自「由7-zip提供的压缩、解压缩程序」· C++ 代码 · 共 94 行

CPP
94
字号
// DLLExports.cpp#include "StdAfx.h"#include "Common/MyInitGuid.h"#include "Common/ComTry.h"#ifdef _WIN32#include "Common/Alloc.h"#endif#include "PPMDEncoder.h"#include "PPMDDecoder.h"// {23170F69-40C1-278B-0304-010000000000}DEFINE_GUID(CLSID_CCompressPPMDDecoder, 0x23170F69, 0x40C1, 0x278B, 0x03, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);// {23170F69-40C1-278B-0304-010000000100}DEFINE_GUID(CLSID_CCompressPPMDEncoder, 0x23170F69, 0x40C1, 0x278B, 0x03, 0x04, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00);extern "C"DLLEXPORT BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/){  #ifdef _WIN32  if (dwReason == DLL_PROCESS_ATTACH)    SetLargePageSize();  #endif	return TRUE;}STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject){  COM_TRY_BEGIN  *outObject = 0;  int correctInterface = (*iid == IID_ICompressCoder);  CMyComPtr<ICompressCoder> coder;  if (*clsid == CLSID_CCompressPPMDDecoder)  {    if (!correctInterface)      return E_NOINTERFACE;    coder = (ICompressCoder *)new NCompress::NPPMD::CDecoder();  }  else if (*clsid == CLSID_CCompressPPMDEncoder)  {    if (!correctInterface)      return E_NOINTERFACE;    coder = (ICompressCoder *)new NCompress::NPPMD::CEncoder();  }  else    return CLASS_E_CLASSNOTAVAILABLE;  *outObject = coder.Detach();  COM_TRY_END  return S_OK;}STDAPI GetNumberOfMethods(UINT32 *numMethods){  *numMethods = 1;  return S_OK;}STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value){  if (index != 0)    return E_INVALIDARG;  ::VariantClear((tagVARIANT *)value);  switch(propID)  {    case NMethodPropID::kID:    {      const char id[] = { 0x03, 0x04, 0x01 };      if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)        value->vt = VT_BSTR;      return S_OK;    }    case NMethodPropID::kName:      if ((value->bstrVal = ::SysAllocString(L"PPMD")) != 0)        value->vt = VT_BSTR;      return S_OK;    case NMethodPropID::kDecoder:      if ((value->bstrVal = ::SysAllocStringByteLen(          (const char *)&CLSID_CCompressPPMDDecoder, sizeof(GUID))) != 0)        value->vt = VT_BSTR;      return S_OK;    case NMethodPropID::kEncoder:      if ((value->bstrVal = ::SysAllocStringByteLen(          (const char *)&CLSID_CCompressPPMDEncoder, sizeof(GUID))) != 0)        value->vt = VT_BSTR;      return S_OK;  }  return S_OK;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?