ReactOS 0.4.15-dev-5836-g942b022
zipfldr.cpp File Reference
#include "precomp.h"
#include <initguid.h>
#include "minizip/ioapi.h"
#include "minizip/iowin32.h"
Include dependency graph for zipfldr.cpp:

Go to the source code of this file.

Classes

class  CZipFldrModule
 

Functions

 DEFINE_GUID (CLSID_ZipFolderStorageHandler, 0xe88dcce0, 0xb7b3, 0x11d1, 0xa9, 0xf0, 0x00, 0xaa, 0x00, 0x60, 0xfa, 0x31)
 
 DEFINE_GUID (CLSID_ZipFolderSendTo, 0x888dca60, 0xfc0a, 0x11cf, 0x8f, 0x0f, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62)
 
 DEFINE_GUID (CLSID_ZipFolderContextMenu, 0xb8cdcb65, 0xb1bf, 0x4b42, 0x94, 0x28, 0x1d, 0xfd, 0xb7, 0xee, 0x92, 0xaf)
 
 DEFINE_GUID (CLSID_ZipFolderRightDragHandler, 0xbd472f60, 0x27fa, 0x11cf, 0xb8, 0xb4, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00)
 
 DEFINE_GUID (CLSID_ZipFolderDropHandler, 0xed9d80b9, 0xd157, 0x457b, 0x91, 0x92, 0x0e, 0x72, 0x80, 0x31, 0x3b, 0xf0)
 
 DEFINE_GUID (CLSID_ZipFolderExtractAllCommand, 0xc3d9647b, 0x8fd9, 0x4ee6, 0x8b, 0xc7, 0x82, 0x7, 0x80, 0x9, 0x10, 0x5a)
 
static void init_zlib ()
 
static BOOL CreateEmptyFile (LPCWSTR pszFile)
 
static HRESULT CreateSendToZip (LPCWSTR pszSendTo)
 
static HRESULT GetDefaultUserSendTo (LPWSTR pszPath)
 
EXTERN_C BOOL WINAPI DllMain (HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 
STDAPI DllCanUnloadNow ()
 
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
STDAPI DllRegisterServer ()
 
STDAPI DllUnregisterServer ()
 
EXTERN_C BOOL WINAPI RouteTheCall (IN HWND hWndOwner, IN HINSTANCE hInstance, IN LPCSTR lpStringArg, IN INT Show)
 

Variables

HMODULE g_hModule = NULL
 
LONG g_ModuleRefCnt = 0
 
CZipFldrModule gModule
 
zlib_filefunc64_def g_FFunc
 

Function Documentation

◆ CreateEmptyFile()

static BOOL CreateEmptyFile ( LPCWSTR  pszFile)
static

Definition at line 51 of file zipfldr.cpp.

52{
57 {
59 return TRUE;
60 }
61 return FALSE;
62}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define CREATE_ALWAYS
Definition: disk.h:72
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90

Referenced by CreateSendToZip().

◆ CreateSendToZip()

static HRESULT CreateSendToZip ( LPCWSTR  pszSendTo)
static

Definition at line 65 of file zipfldr.cpp.

66{
67 WCHAR szTarget[MAX_PATH], szSendToFile[MAX_PATH];
68
69 LoadStringW(g_hModule, IDS_FRIENDLYNAME, szTarget, _countof(szTarget));
70
71 StringCbCopyW(szSendToFile, sizeof(szSendToFile), pszSendTo);
72 PathAppendW(szSendToFile, szTarget);
73 StringCbCatW(szSendToFile, sizeof(szSendToFile), L".ZFSendToTarget");
74 if (!CreateEmptyFile(szSendToFile))
75 {
76 DPRINT1("CreateEmptyFile('%ls')\n", szSendToFile);
77 return E_FAIL;
78 }
79 return S_OK;
80}
#define DPRINT1
Definition: precomp.h:8
#define E_FAIL
Definition: ddrawi.h:102
#define IDS_FRIENDLYNAME
Definition: resource.h:75
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
#define S_OK
Definition: intsafe.h:52
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL CreateEmptyFile(LPCWSTR pszFile)
Definition: zipfldr.cpp:51
HMODULE g_hModule
Definition: zipfldr.cpp:10

Referenced by DllRegisterServer().

◆ DEFINE_GUID() [1/6]

DEFINE_GUID ( CLSID_ZipFolderContextMenu  ,
0xb8cdcb65  ,
0xb1bf  ,
0x4b42  ,
0x94  ,
0x28  ,
0x1d  ,
0xfd  ,
0xb7  ,
0xee  ,
0x92  ,
0xaf   
)

◆ DEFINE_GUID() [2/6]

DEFINE_GUID ( CLSID_ZipFolderDropHandler  ,
0xed9d80b9  ,
0xd157  ,
0x457b  ,
0x91  ,
0x92  ,
0x0e  ,
0x72  ,
0x80  ,
0x31  ,
0x3b  ,
0xf0   
)

◆ DEFINE_GUID() [3/6]

DEFINE_GUID ( CLSID_ZipFolderExtractAllCommand  ,
0xc3d9647b  ,
0x8fd9  ,
0x4ee6  ,
0x8b  ,
0xc7  ,
0x82  ,
0x7  ,
0x80  ,
0x9  ,
0x10  ,
0x5a   
)

◆ DEFINE_GUID() [4/6]

DEFINE_GUID ( CLSID_ZipFolderRightDragHandler  ,
0xbd472f60  ,
0x27fa  ,
0x11cf  ,
0xb8  ,
0xb4  ,
0x44  ,
0x45  ,
0x53  ,
0x54  ,
0x00  ,
0x00   
)

◆ DEFINE_GUID() [5/6]

DEFINE_GUID ( CLSID_ZipFolderSendTo  ,
0x888dca60  ,
0xfc0a  ,
0x11cf  ,
0x8f  ,
0x0f  ,
0x00  ,
0xc0  ,
0x4f  ,
0xd7  ,
0xd0  ,
0x62   
)

◆ DEFINE_GUID() [6/6]

DEFINE_GUID ( CLSID_ZipFolderStorageHandler  ,
0xe88dcce0  ,
0xb7b3  ,
0x11d1  ,
0xa9  ,
0xf0  ,
0x00  ,
0xaa  ,
0x00  ,
0x60  ,
0xfa  ,
0x31   
)

◆ DllCanUnloadNow()

STDAPI DllCanUnloadNow ( void  )

Definition at line 105 of file zipfldr.cpp.

106{
107 if (g_ModuleRefCnt)
108 return S_FALSE;
109 return gModule.DllCanUnloadNow();
110}
HRESULT DllCanUnloadNow()
Definition: atlbase.h:929
#define S_FALSE
Definition: winerror.h:2357
CZipFldrModule gModule
Definition: zipfldr.cpp:37
LONG g_ModuleRefCnt
Definition: zipfldr.cpp:11

◆ DllGetClassObject()

STDAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 112 of file zipfldr.cpp.

113{
114 return gModule.DllGetClassObject(rclsid, riid, ppv);
115}
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:936
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ DllMain()

EXTERN_C BOOL WINAPI DllMain ( HINSTANCE  hInstance,
DWORD  dwReason,
LPVOID  lpReserved 
)

Definition at line 90 of file zipfldr.cpp.

91{
92 switch (dwReason)
93 {
97 gModule.Init(ObjectMap, hInstance, NULL);
98 init_zlib();
99 break;
100 }
101
102 return TRUE;
103}
DWORD dwReason
Definition: misc.cpp:154
HINSTANCE hInstance
Definition: charmap.c:19
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:798
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static void init_zlib()
Definition: zipfldr.cpp:45

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 117 of file zipfldr.cpp.

118{
119 HRESULT hr;
120
123 return hr;
124
126 if (FAILED(hr))
127 return hr;
128
129 WCHAR szSendTo[MAX_PATH];
130 hr = GetDefaultUserSendTo(szSendTo);
131 if (SUCCEEDED(hr))
132 CreateSendToZip(szSendTo);
133
134 return S_OK;
135}
HRESULT WINAPI UpdateRegistryFromResource(LPCTSTR lpszRes, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries=NULL)
Definition: atlbase.h:440
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:941
#define IDR_ZIPFLDR
Definition: resource.h:12
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
HRESULT hr
Definition: shlfolder.c:183
static HRESULT GetDefaultUserSendTo(LPWSTR pszPath)
Definition: zipfldr.cpp:83
static HRESULT CreateSendToZip(LPCWSTR pszSendTo)
Definition: zipfldr.cpp:65

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 137 of file zipfldr.cpp.

138{
139 HRESULT hr;
140
143 return hr;
144
146 if (FAILED(hr))
147 return hr;
148
149 return S_OK;
150}
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:946

◆ GetDefaultUserSendTo()

static HRESULT GetDefaultUserSendTo ( LPWSTR  pszPath)
static

Definition at line 83 of file zipfldr.cpp.

84{
86 SHGFP_TYPE_DEFAULT, pszPath);
87}
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2558
#define CSIDL_SENDTO
Definition: shlobj.h:2034
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2002

Referenced by DllRegisterServer().

◆ init_zlib()

static void init_zlib ( )
static

Definition at line 45 of file zipfldr.cpp.

46{
48}
void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: iowin32.c:457
zlib_filefunc64_def g_FFunc
Definition: zipfldr.cpp:43

Referenced by DllMain().

◆ RouteTheCall()

EXTERN_C BOOL WINAPI RouteTheCall ( IN HWND  hWndOwner,
IN HINSTANCE  hInstance,
IN LPCSTR  lpStringArg,
IN INT  Show 
)

Definition at line 154 of file zipfldr.cpp.

159{
160 CStringW path = lpStringArg;
161 PathRemoveBlanksW(path.GetBuffer());
162 path.ReleaseBuffer();
163 path = L"\"" + path + L"\"";
164 ShellExecuteW(NULL, L"open", L"explorer.exe", path.GetString(), NULL, SW_SHOWNORMAL);
165 return TRUE;
166}
VOID WINAPI PathRemoveBlanksW(LPWSTR lpszPath)
Definition: path.c:920
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2346
#define SW_SHOWNORMAL
Definition: winuser.h:764

Variable Documentation

◆ g_FFunc

Definition at line 43 of file zipfldr.cpp.

Referenced by CZipExtract::Extract(), init_zlib(), and CZipFolder::STDMETHODIMP_().

◆ g_hModule

HMODULE g_hModule = NULL

Definition at line 10 of file zipfldr.cpp.

Referenced by CreateSendToZip(), and DllMain().

◆ g_ModuleRefCnt

LONG g_ModuleRefCnt = 0

Definition at line 11 of file zipfldr.cpp.

Referenced by DllCanUnloadNow().

◆ gModule