misc/libphysfs/lzma/CPP/7zip/Archive/DllExports2.cpp
changeset 13886 99b265e0d1d0
parent 13885 5f819b90d479
child 13887 b172a5d40eee
equal deleted inserted replaced
13885:5f819b90d479 13886:99b265e0d1d0
     1 // DLLExports.cpp
       
     2 
       
     3 #include "StdAfx.h"
       
     4 
       
     5 #include "../../Common/MyInitGuid.h"
       
     6 #include "../../Common/ComTry.h"
       
     7 #include "../../Common/Types.h"
       
     8 #include "../../Windows/PropVariant.h"
       
     9 #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
       
    10 extern "C" 
       
    11 { 
       
    12 #include "../../../C/Alloc.h"
       
    13 }
       
    14 #endif
       
    15 
       
    16 #include "IArchive.h"
       
    17 #include "../ICoder.h"
       
    18 #include "../IPassword.h"
       
    19 
       
    20 HINSTANCE g_hInstance;
       
    21 #ifndef _UNICODE
       
    22 #ifdef _WIN32
       
    23 bool g_IsNT = false;
       
    24 static bool IsItWindowsNT()
       
    25 {
       
    26   OSVERSIONINFO versionInfo;
       
    27   versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
       
    28   if (!::GetVersionEx(&versionInfo)) 
       
    29     return false;
       
    30   return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
       
    31 }
       
    32 #endif
       
    33 #endif
       
    34 
       
    35 extern "C"
       
    36 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
       
    37 {
       
    38   if (dwReason == DLL_PROCESS_ATTACH)
       
    39   {
       
    40     g_hInstance = hInstance;
       
    41     #ifndef _UNICODE
       
    42     #ifdef _WIN32
       
    43     g_IsNT = IsItWindowsNT();
       
    44     #endif
       
    45     #endif
       
    46   }
       
    47   return TRUE;
       
    48 }
       
    49 
       
    50 DEFINE_GUID(CLSID_CArchiveHandler, 
       
    51 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
       
    52 
       
    53 static const UInt16 kDecodeId = 0x2790;
       
    54 
       
    55 DEFINE_GUID(CLSID_CCodec, 
       
    56 0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
       
    57 
       
    58 STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
       
    59 STDAPI CreateArchiver(const GUID *classID, const GUID *iid, void **outObject);
       
    60 
       
    61 STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
       
    62 {
       
    63   // COM_TRY_BEGIN
       
    64   *outObject = 0;
       
    65   if (*iid == IID_ICompressCoder || *iid == IID_ICompressCoder2 || *iid == IID_ICompressFilter)
       
    66   {
       
    67     return CreateCoder(clsid, iid, outObject);
       
    68   }
       
    69   else
       
    70   {
       
    71     return CreateArchiver(clsid, iid, outObject);
       
    72   }
       
    73   // COM_TRY_END
       
    74 }
       
    75 
       
    76 STDAPI SetLargePageMode()
       
    77 {
       
    78   #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
       
    79   SetLargePageSize();
       
    80   #endif
       
    81   return S_OK;
       
    82 }