mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 10:07:10 -06:00
Normalize all the line endings
This commit is contained in:
@@ -1 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="7-Zip.7-Zip.7-zip" type="win32"/><description>7-Zip Extension.</description><dependency> <dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/></dependentAssembly></dependency></assembly>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="7-Zip.7-Zip.7-zip" type="win32"/><description>7-Zip Extension.</description><dependency> <dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/></dependentAssembly></dependency></assembly>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,93 +1,93 @@
|
||||
// ContextMenu.h
|
||||
|
||||
#ifndef __CONTEXT_MENU_H
|
||||
#define __CONTEXT_MENU_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <ShlObj.h>
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
#include "../FileManager/MyCom2.h"
|
||||
|
||||
class CZipContextMenu:
|
||||
public IContextMenu,
|
||||
public IShellExtInit,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
|
||||
enum ECommandInternalID
|
||||
{
|
||||
kCommandNULL,
|
||||
kOpen,
|
||||
kExtract,
|
||||
kExtractHere,
|
||||
kExtractTo,
|
||||
kTest,
|
||||
kCompress,
|
||||
kCompressEmail,
|
||||
kCompressTo7z,
|
||||
kCompressTo7zEmail,
|
||||
kCompressToZip,
|
||||
kCompressToZipEmail,
|
||||
kHash_CRC32,
|
||||
kHash_CRC64,
|
||||
kHash_XXH32,
|
||||
kHash_XXH64,
|
||||
kHash_MD2,
|
||||
kHash_MD4,
|
||||
kHash_MD5,
|
||||
kHash_SHA1,
|
||||
kHash_SHA256,
|
||||
kHash_SHA384,
|
||||
kHash_SHA512,
|
||||
kHash_BLAKE2sp,
|
||||
kHash_All
|
||||
};
|
||||
|
||||
MY_UNKNOWN_IMP2_MT(IContextMenu, IShellExtInit)
|
||||
|
||||
// IShellExtInit
|
||||
STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY hkeyProgID);
|
||||
|
||||
// IContextMenu
|
||||
STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
|
||||
STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici);
|
||||
STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
|
||||
|
||||
HRESULT InitContextMenu(const wchar_t *folder, const wchar_t * const *names, unsigned numFiles);
|
||||
|
||||
CZipContextMenu();
|
||||
~CZipContextMenu();
|
||||
|
||||
private:
|
||||
|
||||
struct CCommandMapItem
|
||||
{
|
||||
ECommandInternalID CommandInternalID;
|
||||
UString Verb;
|
||||
UString HelpString;
|
||||
UString Folder;
|
||||
UString ArcName;
|
||||
UString ArcType;
|
||||
};
|
||||
|
||||
bool _isMenuForFM;
|
||||
UStringVector _fileNames;
|
||||
bool _dropMode;
|
||||
UString _dropPath;
|
||||
CObjectVector<CCommandMapItem> _commandMap;
|
||||
|
||||
HBITMAP _bitmap;
|
||||
|
||||
CBoolPair _elimDup;
|
||||
|
||||
HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames);
|
||||
int FindVerb(const UString &verb);
|
||||
bool FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem);
|
||||
void AddMapItem_ForSubMenu(const char *ver);
|
||||
};
|
||||
|
||||
#endif
|
||||
// ContextMenu.h
|
||||
|
||||
#ifndef __CONTEXT_MENU_H
|
||||
#define __CONTEXT_MENU_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <ShlObj.h>
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
#include "../FileManager/MyCom2.h"
|
||||
|
||||
class CZipContextMenu:
|
||||
public IContextMenu,
|
||||
public IShellExtInit,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
|
||||
enum ECommandInternalID
|
||||
{
|
||||
kCommandNULL,
|
||||
kOpen,
|
||||
kExtract,
|
||||
kExtractHere,
|
||||
kExtractTo,
|
||||
kTest,
|
||||
kCompress,
|
||||
kCompressEmail,
|
||||
kCompressTo7z,
|
||||
kCompressTo7zEmail,
|
||||
kCompressToZip,
|
||||
kCompressToZipEmail,
|
||||
kHash_CRC32,
|
||||
kHash_CRC64,
|
||||
kHash_XXH32,
|
||||
kHash_XXH64,
|
||||
kHash_MD2,
|
||||
kHash_MD4,
|
||||
kHash_MD5,
|
||||
kHash_SHA1,
|
||||
kHash_SHA256,
|
||||
kHash_SHA384,
|
||||
kHash_SHA512,
|
||||
kHash_BLAKE2sp,
|
||||
kHash_All
|
||||
};
|
||||
|
||||
MY_UNKNOWN_IMP2_MT(IContextMenu, IShellExtInit)
|
||||
|
||||
// IShellExtInit
|
||||
STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY hkeyProgID);
|
||||
|
||||
// IContextMenu
|
||||
STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
|
||||
STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici);
|
||||
STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
|
||||
|
||||
HRESULT InitContextMenu(const wchar_t *folder, const wchar_t * const *names, unsigned numFiles);
|
||||
|
||||
CZipContextMenu();
|
||||
~CZipContextMenu();
|
||||
|
||||
private:
|
||||
|
||||
struct CCommandMapItem
|
||||
{
|
||||
ECommandInternalID CommandInternalID;
|
||||
UString Verb;
|
||||
UString HelpString;
|
||||
UString Folder;
|
||||
UString ArcName;
|
||||
UString ArcType;
|
||||
};
|
||||
|
||||
bool _isMenuForFM;
|
||||
UStringVector _fileNames;
|
||||
bool _dropMode;
|
||||
UString _dropPath;
|
||||
CObjectVector<CCommandMapItem> _commandMap;
|
||||
|
||||
HBITMAP _bitmap;
|
||||
|
||||
CBoolPair _elimDup;
|
||||
|
||||
HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames);
|
||||
int FindVerb(const UString &verb);
|
||||
bool FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem);
|
||||
void AddMapItem_ForSubMenu(const char *ver);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
// ContextMenuFlags.h
|
||||
|
||||
#ifndef __CONTEXT_MENU_FLAGS_H
|
||||
#define __CONTEXT_MENU_FLAGS_H
|
||||
|
||||
namespace NContextMenuFlags
|
||||
{
|
||||
const UInt32 kExtract = 1 << 0;
|
||||
const UInt32 kExtractHere = 1 << 1;
|
||||
const UInt32 kExtractTo = 1 << 2;
|
||||
|
||||
const UInt32 kTest = 1 << 4;
|
||||
const UInt32 kOpen = 1 << 5;
|
||||
const UInt32 kOpenAs = 1 << 6;
|
||||
|
||||
const UInt32 kCompress = 1 << 8;
|
||||
const UInt32 kCompressTo7z = 1 << 9;
|
||||
const UInt32 kCompressEmail = 1 << 10;
|
||||
const UInt32 kCompressTo7zEmail = 1 << 11;
|
||||
const UInt32 kCompressToZip = 1 << 12;
|
||||
const UInt32 kCompressToZipEmail = 1 << 13;
|
||||
|
||||
const UInt32 kCRC = (UInt32)1 << 31;
|
||||
}
|
||||
|
||||
#endif
|
||||
// ContextMenuFlags.h
|
||||
|
||||
#ifndef __CONTEXT_MENU_FLAGS_H
|
||||
#define __CONTEXT_MENU_FLAGS_H
|
||||
|
||||
namespace NContextMenuFlags
|
||||
{
|
||||
const UInt32 kExtract = 1 << 0;
|
||||
const UInt32 kExtractHere = 1 << 1;
|
||||
const UInt32 kExtractTo = 1 << 2;
|
||||
|
||||
const UInt32 kTest = 1 << 4;
|
||||
const UInt32 kOpen = 1 << 5;
|
||||
const UInt32 kOpenAs = 1 << 6;
|
||||
|
||||
const UInt32 kCompress = 1 << 8;
|
||||
const UInt32 kCompressTo7z = 1 << 9;
|
||||
const UInt32 kCompressEmail = 1 << 10;
|
||||
const UInt32 kCompressTo7zEmail = 1 << 11;
|
||||
const UInt32 kCompressToZip = 1 << 12;
|
||||
const UInt32 kCompressToZipEmail = 1 << 13;
|
||||
|
||||
const UInt32 kCRC = (UInt32)1 << 31;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,216 +1,216 @@
|
||||
// DLLExports.cpp
|
||||
//
|
||||
// Notes:
|
||||
// Win2000:
|
||||
// If I register at HKCR\Folder\ShellEx then DLL is locked.
|
||||
// otherwise it unloads after explorer closing.
|
||||
// but if I call menu for desktop items it's locked all the time
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <OleCtl.h>
|
||||
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
|
||||
#include "../../../Common/ComTry.h"
|
||||
|
||||
#include "../../../Windows/DLL.h"
|
||||
#include "../../../Windows/ErrorMsg.h"
|
||||
#include "../../../Windows/NtCheck.h"
|
||||
#include "../../../Windows/Registry.h"
|
||||
|
||||
#include "../FileManager/IFolder.h"
|
||||
|
||||
#include "ContextMenu.h"
|
||||
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip ZS Shell Extension");
|
||||
static LPCTSTR const k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
|
||||
// {23170F69-40C1-278A-1000-000100020000}
|
||||
static LPCTSTR const k_Clsid = TEXT("{23170F69-20BB-278A-1000-000100020000}");
|
||||
|
||||
DEFINE_GUID(CLSID_CZipContextMenu,
|
||||
k_7zip_GUID_Data1,
|
||||
k_7zip_GUID_Data2_ZS,
|
||||
k_7zip_GUID_Data3_Common,
|
||||
0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
HINSTANCE g_hInstance = 0;
|
||||
HWND g_HWND = 0;
|
||||
|
||||
LONG g_DllRefCount = 0; // Reference count of this DLL.
|
||||
|
||||
|
||||
// #define ODS(sz) OutputDebugString(L#sz)
|
||||
|
||||
class CShellExtClassFactory:
|
||||
public IClassFactory,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
CShellExtClassFactory() { InterlockedIncrement(&g_DllRefCount); }
|
||||
~CShellExtClassFactory() { InterlockedDecrement(&g_DllRefCount); }
|
||||
|
||||
MY_UNKNOWN_IMP1_MT(IClassFactory)
|
||||
|
||||
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, void**);
|
||||
STDMETHODIMP LockServer(BOOL);
|
||||
};
|
||||
|
||||
STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
|
||||
REFIID riid, void **ppvObj)
|
||||
{
|
||||
// ODS("CShellExtClassFactory::CreateInstance()\r\n");
|
||||
*ppvObj = NULL;
|
||||
if (pUnkOuter)
|
||||
return CLASS_E_NOAGGREGATION;
|
||||
|
||||
CZipContextMenu *shellExt;
|
||||
try
|
||||
{
|
||||
shellExt = new CZipContextMenu();
|
||||
}
|
||||
catch(...) { return E_OUTOFMEMORY; }
|
||||
if (!shellExt)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
HRESULT res = shellExt->QueryInterface(riid, ppvObj);
|
||||
if (res != S_OK)
|
||||
delete shellExt;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CShellExtClassFactory::LockServer(BOOL /* fLock */)
|
||||
{
|
||||
return S_OK; // Check it
|
||||
}
|
||||
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION return FALSE;
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(
|
||||
#ifdef UNDER_CE
|
||||
HANDLE hInstance
|
||||
#else
|
||||
HINSTANCE hInstance
|
||||
#endif
|
||||
, DWORD dwReason, LPVOID)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
// ODS("In DLLMain, DLL_PROCESS_ATTACH\r\n");
|
||||
NT_CHECK
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
// ODS("In DLLMain, DLL_PROCESS_DETACH\r\n");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
// Used to determine whether the DLL can be unloaded by OLE
|
||||
|
||||
STDAPI DllCanUnloadNow(void)
|
||||
{
|
||||
// ODS("In DLLCanUnloadNow\r\n");
|
||||
return (g_DllRefCount == 0 ? S_OK : S_FALSE);
|
||||
}
|
||||
|
||||
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
|
||||
{
|
||||
// ODS("In DllGetClassObject\r\n");
|
||||
*ppv = NULL;
|
||||
if (IsEqualIID(rclsid, CLSID_CZipContextMenu))
|
||||
{
|
||||
CShellExtClassFactory *cf;
|
||||
try
|
||||
{
|
||||
cf = new CShellExtClassFactory;
|
||||
}
|
||||
catch(...) { return E_OUTOFMEMORY; }
|
||||
if (!cf)
|
||||
return E_OUTOFMEMORY;
|
||||
HRESULT res = cf->QueryInterface(riid, ppv);
|
||||
if (res != S_OK)
|
||||
delete cf;
|
||||
return res;
|
||||
}
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
// return _Module.GetClassObject(rclsid, riid, ppv);
|
||||
}
|
||||
|
||||
|
||||
static BOOL RegisterServer()
|
||||
{
|
||||
FString modulePath;
|
||||
if (!NDLL::MyGetModuleFileName(modulePath))
|
||||
return FALSE;
|
||||
const UString modulePathU = fs2us(modulePath);
|
||||
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid;
|
||||
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if (key.Create(HKEY_CLASSES_ROOT, s, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
|
||||
return FALSE;
|
||||
key.SetValue(NULL, k_ShellExtName);
|
||||
NRegistry::CKey keyInproc;
|
||||
if (keyInproc.Create(key, TEXT("InprocServer32"), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
|
||||
return FALSE;
|
||||
keyInproc.SetValue(NULL, modulePathU);
|
||||
keyInproc.SetValue(TEXT("ThreadingModel"), TEXT("Apartment"));
|
||||
}
|
||||
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
if (IsItWindowsNT())
|
||||
#endif
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if (key.Create(HKEY_LOCAL_MACHINE, k_Approved, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) == NOERROR)
|
||||
key.SetValue(k_Clsid, k_ShellExtName);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI DllRegisterServer(void)
|
||||
{
|
||||
return RegisterServer() ? S_OK: SELFREG_E_CLASS;
|
||||
}
|
||||
|
||||
static BOOL UnregisterServer()
|
||||
{
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid;
|
||||
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, s + TEXT("\\InprocServer32"));
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, s);
|
||||
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
if (IsItWindowsNT())
|
||||
#endif
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, k_Approved, 0, KEY_SET_VALUE, &hKey) == NOERROR)
|
||||
{
|
||||
RegDeleteValue(hKey, k_Clsid);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI DllUnregisterServer(void)
|
||||
{
|
||||
return UnregisterServer() ? S_OK: SELFREG_E_CLASS;
|
||||
}
|
||||
// DLLExports.cpp
|
||||
//
|
||||
// Notes:
|
||||
// Win2000:
|
||||
// If I register at HKCR\Folder\ShellEx then DLL is locked.
|
||||
// otherwise it unloads after explorer closing.
|
||||
// but if I call menu for desktop items it's locked all the time
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <OleCtl.h>
|
||||
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
|
||||
#include "../../../Common/ComTry.h"
|
||||
|
||||
#include "../../../Windows/DLL.h"
|
||||
#include "../../../Windows/ErrorMsg.h"
|
||||
#include "../../../Windows/NtCheck.h"
|
||||
#include "../../../Windows/Registry.h"
|
||||
|
||||
#include "../FileManager/IFolder.h"
|
||||
|
||||
#include "ContextMenu.h"
|
||||
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip ZS Shell Extension");
|
||||
static LPCTSTR const k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
|
||||
// {23170F69-40C1-278A-1000-000100020000}
|
||||
static LPCTSTR const k_Clsid = TEXT("{23170F69-20BB-278A-1000-000100020000}");
|
||||
|
||||
DEFINE_GUID(CLSID_CZipContextMenu,
|
||||
k_7zip_GUID_Data1,
|
||||
k_7zip_GUID_Data2_ZS,
|
||||
k_7zip_GUID_Data3_Common,
|
||||
0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
HINSTANCE g_hInstance = 0;
|
||||
HWND g_HWND = 0;
|
||||
|
||||
LONG g_DllRefCount = 0; // Reference count of this DLL.
|
||||
|
||||
|
||||
// #define ODS(sz) OutputDebugString(L#sz)
|
||||
|
||||
class CShellExtClassFactory:
|
||||
public IClassFactory,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
CShellExtClassFactory() { InterlockedIncrement(&g_DllRefCount); }
|
||||
~CShellExtClassFactory() { InterlockedDecrement(&g_DllRefCount); }
|
||||
|
||||
MY_UNKNOWN_IMP1_MT(IClassFactory)
|
||||
|
||||
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, void**);
|
||||
STDMETHODIMP LockServer(BOOL);
|
||||
};
|
||||
|
||||
STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
|
||||
REFIID riid, void **ppvObj)
|
||||
{
|
||||
// ODS("CShellExtClassFactory::CreateInstance()\r\n");
|
||||
*ppvObj = NULL;
|
||||
if (pUnkOuter)
|
||||
return CLASS_E_NOAGGREGATION;
|
||||
|
||||
CZipContextMenu *shellExt;
|
||||
try
|
||||
{
|
||||
shellExt = new CZipContextMenu();
|
||||
}
|
||||
catch(...) { return E_OUTOFMEMORY; }
|
||||
if (!shellExt)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
HRESULT res = shellExt->QueryInterface(riid, ppvObj);
|
||||
if (res != S_OK)
|
||||
delete shellExt;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CShellExtClassFactory::LockServer(BOOL /* fLock */)
|
||||
{
|
||||
return S_OK; // Check it
|
||||
}
|
||||
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION return FALSE;
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(
|
||||
#ifdef UNDER_CE
|
||||
HANDLE hInstance
|
||||
#else
|
||||
HINSTANCE hInstance
|
||||
#endif
|
||||
, DWORD dwReason, LPVOID)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
// ODS("In DLLMain, DLL_PROCESS_ATTACH\r\n");
|
||||
NT_CHECK
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
// ODS("In DLLMain, DLL_PROCESS_DETACH\r\n");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
// Used to determine whether the DLL can be unloaded by OLE
|
||||
|
||||
STDAPI DllCanUnloadNow(void)
|
||||
{
|
||||
// ODS("In DLLCanUnloadNow\r\n");
|
||||
return (g_DllRefCount == 0 ? S_OK : S_FALSE);
|
||||
}
|
||||
|
||||
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
|
||||
{
|
||||
// ODS("In DllGetClassObject\r\n");
|
||||
*ppv = NULL;
|
||||
if (IsEqualIID(rclsid, CLSID_CZipContextMenu))
|
||||
{
|
||||
CShellExtClassFactory *cf;
|
||||
try
|
||||
{
|
||||
cf = new CShellExtClassFactory;
|
||||
}
|
||||
catch(...) { return E_OUTOFMEMORY; }
|
||||
if (!cf)
|
||||
return E_OUTOFMEMORY;
|
||||
HRESULT res = cf->QueryInterface(riid, ppv);
|
||||
if (res != S_OK)
|
||||
delete cf;
|
||||
return res;
|
||||
}
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
// return _Module.GetClassObject(rclsid, riid, ppv);
|
||||
}
|
||||
|
||||
|
||||
static BOOL RegisterServer()
|
||||
{
|
||||
FString modulePath;
|
||||
if (!NDLL::MyGetModuleFileName(modulePath))
|
||||
return FALSE;
|
||||
const UString modulePathU = fs2us(modulePath);
|
||||
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid;
|
||||
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if (key.Create(HKEY_CLASSES_ROOT, s, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
|
||||
return FALSE;
|
||||
key.SetValue(NULL, k_ShellExtName);
|
||||
NRegistry::CKey keyInproc;
|
||||
if (keyInproc.Create(key, TEXT("InprocServer32"), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
|
||||
return FALSE;
|
||||
keyInproc.SetValue(NULL, modulePathU);
|
||||
keyInproc.SetValue(TEXT("ThreadingModel"), TEXT("Apartment"));
|
||||
}
|
||||
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
if (IsItWindowsNT())
|
||||
#endif
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if (key.Create(HKEY_LOCAL_MACHINE, k_Approved, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) == NOERROR)
|
||||
key.SetValue(k_Clsid, k_ShellExtName);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI DllRegisterServer(void)
|
||||
{
|
||||
return RegisterServer() ? S_OK: SELFREG_E_CLASS;
|
||||
}
|
||||
|
||||
static BOOL UnregisterServer()
|
||||
{
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid;
|
||||
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, s + TEXT("\\InprocServer32"));
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, s);
|
||||
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
if (IsItWindowsNT())
|
||||
#endif
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, k_Approved, 0, KEY_SET_VALUE, &hKey) == NOERROR)
|
||||
{
|
||||
RegDeleteValue(hKey, k_Clsid);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI DllUnregisterServer(void)
|
||||
{
|
||||
return UnregisterServer() ? S_OK: SELFREG_E_CLASS;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
; 7-zip.def
|
||||
|
||||
LIBRARY "7-zip"
|
||||
|
||||
EXPORTS
|
||||
DllCanUnloadNow PRIVATE
|
||||
DllGetClassObject PRIVATE
|
||||
DllRegisterServer PRIVATE
|
||||
DllUnregisterServer PRIVATE
|
||||
; 7-zip.def
|
||||
|
||||
LIBRARY "7-zip"
|
||||
|
||||
EXPORTS
|
||||
DllCanUnloadNow PRIVATE
|
||||
DllGetClassObject PRIVATE
|
||||
DllRegisterServer PRIVATE
|
||||
DllUnregisterServer PRIVATE
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Explorer"=".\Explorer.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Explorer"=".\Explorer.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
// MyMessages.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "MyMessages.h"
|
||||
|
||||
#include "../../../Windows/ErrorMsg.h"
|
||||
#include "../../../Windows/ResourceString.h"
|
||||
|
||||
#include "../FileManager/LangUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
void ShowErrorMessage(HWND window, LPCWSTR message)
|
||||
{
|
||||
::MessageBoxW(window, message, L"7-Zip-Zstandard", MB_OK | MB_ICONSTOP);
|
||||
}
|
||||
|
||||
void ShowErrorMessageHwndRes(HWND window, UINT resID)
|
||||
{
|
||||
ShowErrorMessage(window, LangString(resID));
|
||||
}
|
||||
|
||||
void ShowErrorMessageRes(UINT resID)
|
||||
{
|
||||
ShowErrorMessageHwndRes(0, resID);
|
||||
}
|
||||
|
||||
void ShowErrorMessageDWORD(HWND window, DWORD errorCode)
|
||||
{
|
||||
ShowErrorMessage(window, NError::MyFormatMessage(errorCode));
|
||||
}
|
||||
|
||||
void ShowLastErrorMessage(HWND window)
|
||||
{
|
||||
ShowErrorMessageDWORD(window, ::GetLastError());
|
||||
}
|
||||
// MyMessages.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "MyMessages.h"
|
||||
|
||||
#include "../../../Windows/ErrorMsg.h"
|
||||
#include "../../../Windows/ResourceString.h"
|
||||
|
||||
#include "../FileManager/LangUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
void ShowErrorMessage(HWND window, LPCWSTR message)
|
||||
{
|
||||
::MessageBoxW(window, message, L"7-Zip-Zstandard", MB_OK | MB_ICONSTOP);
|
||||
}
|
||||
|
||||
void ShowErrorMessageHwndRes(HWND window, UINT resID)
|
||||
{
|
||||
ShowErrorMessage(window, LangString(resID));
|
||||
}
|
||||
|
||||
void ShowErrorMessageRes(UINT resID)
|
||||
{
|
||||
ShowErrorMessageHwndRes(0, resID);
|
||||
}
|
||||
|
||||
void ShowErrorMessageDWORD(HWND window, DWORD errorCode)
|
||||
{
|
||||
ShowErrorMessage(window, NError::MyFormatMessage(errorCode));
|
||||
}
|
||||
|
||||
void ShowLastErrorMessage(HWND window)
|
||||
{
|
||||
ShowErrorMessageDWORD(window, ::GetLastError());
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// MyMessages.h
|
||||
|
||||
#ifndef __MY_MESSAGES_H
|
||||
#define __MY_MESSAGES_H
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
void ShowErrorMessage(HWND window, LPCWSTR message);
|
||||
inline void ShowErrorMessage(LPCWSTR message) { ShowErrorMessage(0, message); }
|
||||
|
||||
void ShowErrorMessageHwndRes(HWND window, UInt32 langID);
|
||||
void ShowErrorMessageRes(UInt32 langID);
|
||||
|
||||
void ShowLastErrorMessage(HWND window = 0);
|
||||
|
||||
#endif
|
||||
// MyMessages.h
|
||||
|
||||
#ifndef __MY_MESSAGES_H
|
||||
#define __MY_MESSAGES_H
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
void ShowErrorMessage(HWND window, LPCWSTR message);
|
||||
inline void ShowErrorMessage(LPCWSTR message) { ShowErrorMessage(0, message); }
|
||||
|
||||
void ShowErrorMessageHwndRes(HWND window, UInt32 langID);
|
||||
void ShowErrorMessageRes(UInt32 langID);
|
||||
|
||||
void ShowLastErrorMessage(HWND window = 0);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,224 +1,224 @@
|
||||
// RegistryContextMenu.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "../../../Windows/Registry.h"
|
||||
|
||||
#include "RegistryContextMenu.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NRegistry;
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
// does extension can work, if Approved is removed ?
|
||||
// CLISID (and Approved ?) items are separated for 32-bit and 64-bit code.
|
||||
// shellex items shared by 32-bit and 64-bit code?
|
||||
|
||||
#define k_Clsid_A "{23170F69-20BB-278A-1000-000100020000}"
|
||||
|
||||
static LPCTSTR const k_Clsid = TEXT(k_Clsid_A);
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip ZS Shell Extension");
|
||||
|
||||
static LPCTSTR const k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
static LPCTSTR const k_Inproc = TEXT("InprocServer32");
|
||||
|
||||
static LPCSTR const k_KeyPostfix_ContextMenu = "\\shellex\\ContextMenuHandlers\\7-Zip-Zstandard";
|
||||
static LPCSTR const k_KeyPostfix_DragDrop = "\\shellex\\DragDropHandlers\\7-Zip-Zstandard";
|
||||
|
||||
static LPCSTR const k_KeyName_File = "*";
|
||||
static LPCSTR const k_KeyName_Folder = "Folder";
|
||||
static LPCSTR const k_KeyName_Directory = "Directory";
|
||||
static LPCSTR const k_KeyName_Drive = "Drive";
|
||||
|
||||
static LPCSTR const k_shellex_Prefixes[] =
|
||||
{
|
||||
k_KeyName_File,
|
||||
k_KeyName_Folder,
|
||||
k_KeyName_Directory,
|
||||
k_KeyName_Drive
|
||||
};
|
||||
|
||||
static const bool k_shellex_Statuses[2][4] =
|
||||
{
|
||||
{ true, true, true, false },
|
||||
{ false, false, true, true }
|
||||
};
|
||||
|
||||
|
||||
// can we use static RegDeleteKeyExW in _WIN64 mode?
|
||||
// is it supported by Windows 2003 x64?
|
||||
|
||||
/*
|
||||
#ifdef _WIN64
|
||||
|
||||
#define INIT_REG_WOW
|
||||
|
||||
#else
|
||||
*/
|
||||
|
||||
typedef WINADVAPI LONG (APIENTRY *Func_RegDeleteKeyExW)(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired, DWORD Reserved);
|
||||
static Func_RegDeleteKeyExW func_RegDeleteKeyExW;
|
||||
|
||||
static void Init_RegDeleteKeyExW()
|
||||
{
|
||||
if (!func_RegDeleteKeyExW)
|
||||
func_RegDeleteKeyExW = (Func_RegDeleteKeyExW)
|
||||
GetProcAddress(GetModuleHandleW(L"advapi32.dll"), "RegDeleteKeyExW");
|
||||
}
|
||||
|
||||
#define INIT_REG_WOW if (wow != 0) Init_RegDeleteKeyExW();
|
||||
|
||||
// #endif
|
||||
|
||||
static LONG MyRegistry_DeleteKey(HKEY parentKey, LPCTSTR name, UInt32 wow)
|
||||
{
|
||||
if (wow == 0)
|
||||
return RegDeleteKey(parentKey, name);
|
||||
|
||||
/*
|
||||
#ifdef _WIN64
|
||||
return RegDeleteKeyExW
|
||||
#else
|
||||
*/
|
||||
if (!func_RegDeleteKeyExW)
|
||||
return E_NOTIMPL;
|
||||
return func_RegDeleteKeyExW
|
||||
// #endif
|
||||
(parentKey, GetUnicodeString(name), wow, 0);
|
||||
}
|
||||
|
||||
static LONG MyRegistry_DeleteKey_HKCR(LPCTSTR name, UInt32 wow)
|
||||
{
|
||||
return MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, name, wow);
|
||||
}
|
||||
|
||||
// static NSynchronization::CCriticalSection g_CS;
|
||||
|
||||
static AString Get_ContextMenuHandler_KeyName(LPCSTR keyName)
|
||||
{ return (AString)keyName + k_KeyPostfix_ContextMenu; }
|
||||
|
||||
/*
|
||||
static CSysString Get_DragDropHandler_KeyName(LPCTSTR keyName)
|
||||
{ return (AString)keyName + k_KeyPostfix_DragDrop); }
|
||||
*/
|
||||
|
||||
static bool CheckHandlerCommon(const AString &keyName, UInt32 wow)
|
||||
{
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CLASSES_ROOT, (CSysString)keyName, KEY_READ | wow) != ERROR_SUCCESS)
|
||||
return false;
|
||||
CSysString value;
|
||||
if (key.QueryValue(NULL, value) != ERROR_SUCCESS)
|
||||
return false;
|
||||
return StringsAreEqualNoCase_Ascii(value, k_Clsid_A);
|
||||
}
|
||||
|
||||
bool CheckContextMenuHandler(const UString &path, UInt32 wow)
|
||||
{
|
||||
// NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid_A;
|
||||
s += "\\InprocServer32";
|
||||
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if (key.Open(HKEY_CLASSES_ROOT, s, KEY_READ | wow) != ERROR_SUCCESS)
|
||||
return false;
|
||||
UString regPath;
|
||||
if (key.QueryValue(NULL, regPath) != ERROR_SUCCESS)
|
||||
return false;
|
||||
if (!path.IsEqualTo_NoCase(regPath))
|
||||
return false;
|
||||
}
|
||||
|
||||
return
|
||||
CheckHandlerCommon(Get_ContextMenuHandler_KeyName(k_KeyName_File), wow);
|
||||
/*
|
||||
&& CheckHandlerCommon(Get_ContextMenuHandler_KeyName(k_KeyName_Directory), wow)
|
||||
// && CheckHandlerCommon(Get_ContextMenuHandler_KeyName(k_KeyName_Folder))
|
||||
|
||||
&& CheckHandlerCommon(Get_DragDropHandler_KeyName(k_KeyName_Directory), wow)
|
||||
&& CheckHandlerCommon(Get_DragDropHandler_KeyName(k_KeyName_Drive), wow);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
static LONG MyCreateKey(CKey &key, HKEY parentKey, LPCTSTR keyName, UInt32 wow)
|
||||
{
|
||||
return key.Create(parentKey, keyName, REG_NONE,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | wow);
|
||||
}
|
||||
|
||||
LONG SetContextMenuHandler(bool setMode, const UString &path, UInt32 wow)
|
||||
{
|
||||
// NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
|
||||
INIT_REG_WOW
|
||||
|
||||
LONG res;
|
||||
|
||||
{
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid_A;
|
||||
|
||||
if (setMode)
|
||||
{
|
||||
{
|
||||
CKey key;
|
||||
res = MyCreateKey(key, HKEY_CLASSES_ROOT, s, wow);
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
key.SetValue(NULL, k_ShellExtName);
|
||||
CKey keyInproc;
|
||||
res = MyCreateKey(keyInproc, key, k_Inproc, wow);
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
res = keyInproc.SetValue(NULL, path);
|
||||
keyInproc.SetValue(TEXT("ThreadingModel"), TEXT("Apartment"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
CKey key;
|
||||
if (MyCreateKey(key, HKEY_LOCAL_MACHINE, k_Approved, wow) == ERROR_SUCCESS)
|
||||
key.SetValue(k_Clsid, k_ShellExtName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CSysString s2 (s);
|
||||
s2 += "\\InprocServer32";
|
||||
|
||||
MyRegistry_DeleteKey_HKCR(s2, wow);
|
||||
res = MyRegistry_DeleteKey_HKCR(s, wow);
|
||||
}
|
||||
}
|
||||
|
||||
// shellex items probably are shared beween 32-bit and 64-bit apps. So we don't delete items for delete operation.
|
||||
if (setMode)
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
for (unsigned k = 0; k < ARRAY_SIZE(k_shellex_Prefixes); k++)
|
||||
{
|
||||
CSysString s (k_shellex_Prefixes[k]);
|
||||
s += (i == 0 ? k_KeyPostfix_ContextMenu : k_KeyPostfix_DragDrop);
|
||||
if (k_shellex_Statuses[i][k])
|
||||
{
|
||||
CKey key;
|
||||
MyCreateKey(key, HKEY_CLASSES_ROOT, s, wow);
|
||||
key.SetValue(NULL, k_Clsid);
|
||||
}
|
||||
else
|
||||
MyRegistry_DeleteKey_HKCR(s, wow);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
// RegistryContextMenu.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "../../../Windows/Registry.h"
|
||||
|
||||
#include "RegistryContextMenu.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NRegistry;
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
// does extension can work, if Approved is removed ?
|
||||
// CLISID (and Approved ?) items are separated for 32-bit and 64-bit code.
|
||||
// shellex items shared by 32-bit and 64-bit code?
|
||||
|
||||
#define k_Clsid_A "{23170F69-20BB-278A-1000-000100020000}"
|
||||
|
||||
static LPCTSTR const k_Clsid = TEXT(k_Clsid_A);
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip ZS Shell Extension");
|
||||
|
||||
static LPCTSTR const k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
static LPCTSTR const k_Inproc = TEXT("InprocServer32");
|
||||
|
||||
static LPCSTR const k_KeyPostfix_ContextMenu = "\\shellex\\ContextMenuHandlers\\7-Zip-Zstandard";
|
||||
static LPCSTR const k_KeyPostfix_DragDrop = "\\shellex\\DragDropHandlers\\7-Zip-Zstandard";
|
||||
|
||||
static LPCSTR const k_KeyName_File = "*";
|
||||
static LPCSTR const k_KeyName_Folder = "Folder";
|
||||
static LPCSTR const k_KeyName_Directory = "Directory";
|
||||
static LPCSTR const k_KeyName_Drive = "Drive";
|
||||
|
||||
static LPCSTR const k_shellex_Prefixes[] =
|
||||
{
|
||||
k_KeyName_File,
|
||||
k_KeyName_Folder,
|
||||
k_KeyName_Directory,
|
||||
k_KeyName_Drive
|
||||
};
|
||||
|
||||
static const bool k_shellex_Statuses[2][4] =
|
||||
{
|
||||
{ true, true, true, false },
|
||||
{ false, false, true, true }
|
||||
};
|
||||
|
||||
|
||||
// can we use static RegDeleteKeyExW in _WIN64 mode?
|
||||
// is it supported by Windows 2003 x64?
|
||||
|
||||
/*
|
||||
#ifdef _WIN64
|
||||
|
||||
#define INIT_REG_WOW
|
||||
|
||||
#else
|
||||
*/
|
||||
|
||||
typedef WINADVAPI LONG (APIENTRY *Func_RegDeleteKeyExW)(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired, DWORD Reserved);
|
||||
static Func_RegDeleteKeyExW func_RegDeleteKeyExW;
|
||||
|
||||
static void Init_RegDeleteKeyExW()
|
||||
{
|
||||
if (!func_RegDeleteKeyExW)
|
||||
func_RegDeleteKeyExW = (Func_RegDeleteKeyExW)
|
||||
GetProcAddress(GetModuleHandleW(L"advapi32.dll"), "RegDeleteKeyExW");
|
||||
}
|
||||
|
||||
#define INIT_REG_WOW if (wow != 0) Init_RegDeleteKeyExW();
|
||||
|
||||
// #endif
|
||||
|
||||
static LONG MyRegistry_DeleteKey(HKEY parentKey, LPCTSTR name, UInt32 wow)
|
||||
{
|
||||
if (wow == 0)
|
||||
return RegDeleteKey(parentKey, name);
|
||||
|
||||
/*
|
||||
#ifdef _WIN64
|
||||
return RegDeleteKeyExW
|
||||
#else
|
||||
*/
|
||||
if (!func_RegDeleteKeyExW)
|
||||
return E_NOTIMPL;
|
||||
return func_RegDeleteKeyExW
|
||||
// #endif
|
||||
(parentKey, GetUnicodeString(name), wow, 0);
|
||||
}
|
||||
|
||||
static LONG MyRegistry_DeleteKey_HKCR(LPCTSTR name, UInt32 wow)
|
||||
{
|
||||
return MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, name, wow);
|
||||
}
|
||||
|
||||
// static NSynchronization::CCriticalSection g_CS;
|
||||
|
||||
static AString Get_ContextMenuHandler_KeyName(LPCSTR keyName)
|
||||
{ return (AString)keyName + k_KeyPostfix_ContextMenu; }
|
||||
|
||||
/*
|
||||
static CSysString Get_DragDropHandler_KeyName(LPCTSTR keyName)
|
||||
{ return (AString)keyName + k_KeyPostfix_DragDrop); }
|
||||
*/
|
||||
|
||||
static bool CheckHandlerCommon(const AString &keyName, UInt32 wow)
|
||||
{
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CLASSES_ROOT, (CSysString)keyName, KEY_READ | wow) != ERROR_SUCCESS)
|
||||
return false;
|
||||
CSysString value;
|
||||
if (key.QueryValue(NULL, value) != ERROR_SUCCESS)
|
||||
return false;
|
||||
return StringsAreEqualNoCase_Ascii(value, k_Clsid_A);
|
||||
}
|
||||
|
||||
bool CheckContextMenuHandler(const UString &path, UInt32 wow)
|
||||
{
|
||||
// NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid_A;
|
||||
s += "\\InprocServer32";
|
||||
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if (key.Open(HKEY_CLASSES_ROOT, s, KEY_READ | wow) != ERROR_SUCCESS)
|
||||
return false;
|
||||
UString regPath;
|
||||
if (key.QueryValue(NULL, regPath) != ERROR_SUCCESS)
|
||||
return false;
|
||||
if (!path.IsEqualTo_NoCase(regPath))
|
||||
return false;
|
||||
}
|
||||
|
||||
return
|
||||
CheckHandlerCommon(Get_ContextMenuHandler_KeyName(k_KeyName_File), wow);
|
||||
/*
|
||||
&& CheckHandlerCommon(Get_ContextMenuHandler_KeyName(k_KeyName_Directory), wow)
|
||||
// && CheckHandlerCommon(Get_ContextMenuHandler_KeyName(k_KeyName_Folder))
|
||||
|
||||
&& CheckHandlerCommon(Get_DragDropHandler_KeyName(k_KeyName_Directory), wow)
|
||||
&& CheckHandlerCommon(Get_DragDropHandler_KeyName(k_KeyName_Drive), wow);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
static LONG MyCreateKey(CKey &key, HKEY parentKey, LPCTSTR keyName, UInt32 wow)
|
||||
{
|
||||
return key.Create(parentKey, keyName, REG_NONE,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | wow);
|
||||
}
|
||||
|
||||
LONG SetContextMenuHandler(bool setMode, const UString &path, UInt32 wow)
|
||||
{
|
||||
// NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
|
||||
INIT_REG_WOW
|
||||
|
||||
LONG res;
|
||||
|
||||
{
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid_A;
|
||||
|
||||
if (setMode)
|
||||
{
|
||||
{
|
||||
CKey key;
|
||||
res = MyCreateKey(key, HKEY_CLASSES_ROOT, s, wow);
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
key.SetValue(NULL, k_ShellExtName);
|
||||
CKey keyInproc;
|
||||
res = MyCreateKey(keyInproc, key, k_Inproc, wow);
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
res = keyInproc.SetValue(NULL, path);
|
||||
keyInproc.SetValue(TEXT("ThreadingModel"), TEXT("Apartment"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
CKey key;
|
||||
if (MyCreateKey(key, HKEY_LOCAL_MACHINE, k_Approved, wow) == ERROR_SUCCESS)
|
||||
key.SetValue(k_Clsid, k_ShellExtName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CSysString s2 (s);
|
||||
s2 += "\\InprocServer32";
|
||||
|
||||
MyRegistry_DeleteKey_HKCR(s2, wow);
|
||||
res = MyRegistry_DeleteKey_HKCR(s, wow);
|
||||
}
|
||||
}
|
||||
|
||||
// shellex items probably are shared beween 32-bit and 64-bit apps. So we don't delete items for delete operation.
|
||||
if (setMode)
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
for (unsigned k = 0; k < ARRAY_SIZE(k_shellex_Prefixes); k++)
|
||||
{
|
||||
CSysString s (k_shellex_Prefixes[k]);
|
||||
s += (i == 0 ? k_KeyPostfix_ContextMenu : k_KeyPostfix_DragDrop);
|
||||
if (k_shellex_Statuses[i][k])
|
||||
{
|
||||
CKey key;
|
||||
MyCreateKey(key, HKEY_CLASSES_ROOT, s, wow);
|
||||
key.SetValue(NULL, k_Clsid);
|
||||
}
|
||||
else
|
||||
MyRegistry_DeleteKey_HKCR(s, wow);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// RegistryContextMenu.h
|
||||
|
||||
#ifndef __REGISTRY_CONTEXT_MENU_H
|
||||
#define __REGISTRY_CONTEXT_MENU_H
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
bool CheckContextMenuHandler(const UString &path, UInt32 wow = 0);
|
||||
LONG SetContextMenuHandler(bool setMode, const UString &path, UInt32 wow = 0);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// RegistryContextMenu.h
|
||||
|
||||
#ifndef __REGISTRY_CONTEXT_MENU_H
|
||||
#define __REGISTRY_CONTEXT_MENU_H
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
bool CheckContextMenuHandler(const UString &path, UInt32 wow = 0);
|
||||
LONG SetContextMenuHandler(bool setMode, const UString &path, UInt32 wow = 0);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "stdafx.h"
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
// #define _WIN32_WINNT 0x0400
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#define WINVER _WIN32_WINNT
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#include <ShlObj.h>
|
||||
|
||||
#endif
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
// #define _WIN32_WINNT 0x0400
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#define WINVER _WIN32_WINNT
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#include <ShlObj.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
PROG = 7-zip.dll
|
||||
DEF_FILE = Explorer.def
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DLANG \
|
||||
|
||||
!IFDEF UNDER_CE
|
||||
LIBS = $(LIBS) Commctrl.lib
|
||||
!ELSE
|
||||
LIBS = $(LIBS) htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH
|
||||
!ENDIF
|
||||
|
||||
EXPLORER_OBJS = \
|
||||
$O\DllExportsExplorer.obj \
|
||||
$O\ContextMenu.obj \
|
||||
$O\MyMessages.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\IntToString.obj \
|
||||
$O\Lang.obj \
|
||||
$O\MyString.obj \
|
||||
$O\MyVector.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\Random.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\UTFConvert.obj \
|
||||
$O\Wildcard.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\ErrorMsg.obj \
|
||||
$O\FileDir.obj \
|
||||
$O\FileFind.obj \
|
||||
$O\FileIO.obj \
|
||||
$O\FileName.obj \
|
||||
$O\MemoryLock.obj \
|
||||
$O\Menu.obj \
|
||||
$O\ProcessUtils.obj \
|
||||
$O\Registry.obj \
|
||||
$O\ResourceString.obj \
|
||||
$O\Shell.obj \
|
||||
$O\Synchronization.obj \
|
||||
$O\Window.obj \
|
||||
|
||||
!IFDEF UNDER_CE
|
||||
|
||||
WIN_OBJS = $(WIN_OBJS) \
|
||||
$O\CommonDialog.obj \
|
||||
|
||||
!ENDIF
|
||||
|
||||
WIN_CTRL_OBJS = \
|
||||
$O\Dialog.obj \
|
||||
$O\ListView.obj \
|
||||
|
||||
UI_COMMON_OBJS = \
|
||||
$O\ArchiveName.obj \
|
||||
$O\CompressCall.obj \
|
||||
$O\ExtractingFilePath.obj \
|
||||
$O\ZipRegistry.obj \
|
||||
|
||||
FM_OBJS = \
|
||||
$O\FormatUtils.obj \
|
||||
$O\HelpUtils.obj \
|
||||
$O\LangUtils.obj \
|
||||
$O\ProgramLocation.obj \
|
||||
$O\RegistryUtils.obj \
|
||||
$O\StringUtils.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\CpuArch.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
!include "../../7zip.mak"
|
||||
PROG = 7-zip.dll
|
||||
DEF_FILE = Explorer.def
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DLANG \
|
||||
|
||||
!IFDEF UNDER_CE
|
||||
LIBS = $(LIBS) Commctrl.lib
|
||||
!ELSE
|
||||
LIBS = $(LIBS) htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH
|
||||
!ENDIF
|
||||
|
||||
EXPLORER_OBJS = \
|
||||
$O\DllExportsExplorer.obj \
|
||||
$O\ContextMenu.obj \
|
||||
$O\MyMessages.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\IntToString.obj \
|
||||
$O\Lang.obj \
|
||||
$O\MyString.obj \
|
||||
$O\MyVector.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\Random.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\UTFConvert.obj \
|
||||
$O\Wildcard.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\ErrorMsg.obj \
|
||||
$O\FileDir.obj \
|
||||
$O\FileFind.obj \
|
||||
$O\FileIO.obj \
|
||||
$O\FileName.obj \
|
||||
$O\MemoryLock.obj \
|
||||
$O\Menu.obj \
|
||||
$O\ProcessUtils.obj \
|
||||
$O\Registry.obj \
|
||||
$O\ResourceString.obj \
|
||||
$O\Shell.obj \
|
||||
$O\Synchronization.obj \
|
||||
$O\Window.obj \
|
||||
|
||||
!IFDEF UNDER_CE
|
||||
|
||||
WIN_OBJS = $(WIN_OBJS) \
|
||||
$O\CommonDialog.obj \
|
||||
|
||||
!ENDIF
|
||||
|
||||
WIN_CTRL_OBJS = \
|
||||
$O\Dialog.obj \
|
||||
$O\ListView.obj \
|
||||
|
||||
UI_COMMON_OBJS = \
|
||||
$O\ArchiveName.obj \
|
||||
$O\CompressCall.obj \
|
||||
$O\ExtractingFilePath.obj \
|
||||
$O\ZipRegistry.obj \
|
||||
|
||||
FM_OBJS = \
|
||||
$O\FormatUtils.obj \
|
||||
$O\HelpUtils.obj \
|
||||
$O\LangUtils.obj \
|
||||
$O\ProgramLocation.obj \
|
||||
$O\RegistryUtils.obj \
|
||||
$O\StringUtils.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\CpuArch.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#define IDS_CONTEXT_FOLDER 2320
|
||||
#define IDS_CONTEXT_ARCHIVE 2321
|
||||
#define IDS_CONTEXT_OPEN 2322
|
||||
#define IDS_CONTEXT_EXTRACT 2323
|
||||
#define IDS_CONTEXT_COMPRESS 2324
|
||||
#define IDS_CONTEXT_TEST 2325
|
||||
#define IDS_CONTEXT_EXTRACT_HERE 2326
|
||||
#define IDS_CONTEXT_EXTRACT_TO 2327
|
||||
#define IDS_CONTEXT_COMPRESS_TO 2328
|
||||
#define IDS_CONTEXT_COMPRESS_EMAIL 2329
|
||||
#define IDS_CONTEXT_COMPRESS_TO_EMAIL 2330
|
||||
|
||||
#define IDB_MENU_LOGO 190
|
||||
#define IDS_CONTEXT_FOLDER 2320
|
||||
#define IDS_CONTEXT_ARCHIVE 2321
|
||||
#define IDS_CONTEXT_OPEN 2322
|
||||
#define IDS_CONTEXT_EXTRACT 2323
|
||||
#define IDS_CONTEXT_COMPRESS 2324
|
||||
#define IDS_CONTEXT_TEST 2325
|
||||
#define IDS_CONTEXT_EXTRACT_HERE 2326
|
||||
#define IDS_CONTEXT_EXTRACT_TO 2327
|
||||
#define IDS_CONTEXT_COMPRESS_TO 2328
|
||||
#define IDS_CONTEXT_COMPRESS_EMAIL 2329
|
||||
#define IDS_CONTEXT_COMPRESS_TO_EMAIL 2330
|
||||
|
||||
#define IDB_MENU_LOGO 190
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
#include "resource2.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("7-Zip Shell Extension", "7-zip")
|
||||
|
||||
#ifndef UNDER_CE
|
||||
1 24 MOVEABLE PURE "7-zip.dll.manifest"
|
||||
#endif
|
||||
#include "../../MyVersionInfo.rc"
|
||||
#include "resource2.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("7-Zip Shell Extension", "7-zip")
|
||||
|
||||
#ifndef UNDER_CE
|
||||
1 24 MOVEABLE PURE "7-zip.dll.manifest"
|
||||
#endif
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#include "resource.h"
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_CONTEXT_FOLDER "<Folder>"
|
||||
IDS_CONTEXT_ARCHIVE "<Archive>"
|
||||
IDS_CONTEXT_OPEN "Open archive"
|
||||
IDS_CONTEXT_EXTRACT "Extract files..."
|
||||
IDS_CONTEXT_COMPRESS "Add to archive..."
|
||||
IDS_CONTEXT_TEST "Test archive"
|
||||
IDS_CONTEXT_EXTRACT_HERE "Extract Here"
|
||||
IDS_CONTEXT_EXTRACT_TO "Extract to {0}"
|
||||
IDS_CONTEXT_COMPRESS_TO "Add to {0}"
|
||||
IDS_CONTEXT_COMPRESS_EMAIL "Compress and email..."
|
||||
IDS_CONTEXT_COMPRESS_TO_EMAIL "Compress to {0} and email"
|
||||
END
|
||||
|
||||
IDB_MENU_LOGO BITMAP "../../UI/Explorer/MenuLogo.bmp"
|
||||
#include "resource.h"
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_CONTEXT_FOLDER "<Folder>"
|
||||
IDS_CONTEXT_ARCHIVE "<Archive>"
|
||||
IDS_CONTEXT_OPEN "Open archive"
|
||||
IDS_CONTEXT_EXTRACT "Extract files..."
|
||||
IDS_CONTEXT_COMPRESS "Add to archive..."
|
||||
IDS_CONTEXT_TEST "Test archive"
|
||||
IDS_CONTEXT_EXTRACT_HERE "Extract Here"
|
||||
IDS_CONTEXT_EXTRACT_TO "Extract to {0}"
|
||||
IDS_CONTEXT_COMPRESS_TO "Add to {0}"
|
||||
IDS_CONTEXT_COMPRESS_EMAIL "Compress and email..."
|
||||
IDS_CONTEXT_COMPRESS_TO_EMAIL "Compress to {0} and email"
|
||||
END
|
||||
|
||||
IDB_MENU_LOGO BITMAP "../../UI/Explorer/MenuLogo.bmp"
|
||||
|
||||
Reference in New Issue
Block a user