DllExports2.cpp 1.8 KB

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