|
// CreateHash.h : Declaration of the CCreateHash
#pragma once
#include "resource.h" // main symbols
#include "CtxCreateHash.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
// CCreateHash
class ATL_NO_VTABLE CCreateHash :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CCreateHash, &CLSID_CreateHash>,
public IDispatchImpl<ICreateHash, &IID_ICreateHash,
&LIBID_CtxCreateHashLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public IShellExtInit,
public IContextMenu
{
public:
CCreateHash() { }
protected:
// Parallel Vectors of various hashes and hash values
// (in string format, not byte) for a given file
//
// file = "C:\Winnt\text.txt"
//
// hashes[0] = "MD5"
// hashes[1] = "SHA-1"
// hashes[2] = "SHA-256"
//
// filehashes[0] = "CD5B65B7ACDBA247EDE28FBA169F2F26"
// filehashes[1] = "5751B71EFED61D91B3AD048C0C81F15397DAF434"
// filehashes[2] = "9AE08AA516BA5739 ... 282C16841B9866F2"
bool CalculateFileHashes( const std::wstring& file,
std::vector< std::wstring >& hashes,
std::vector< std::wstring >& filehashes );
// Transforms
// 'CD4FE51FD1C9A4F311BA0E7E920FB957D2E6DB804AB00FDFEBDFDBA9BB586172'
// to
// 'CD4FE51FD1C9A4F3...EBDFDBA9BB586172
//
// Useful for MessageBoxes to keep the size down
// Starts snipping when hash.length() > 32
std::wstring Snip( const std::wstring& hash );
// Transforms
// C:\CtxCreateHash\CtxCreateHash.zip
// to
// CtxCreateHash.zip
std::wstring FileName( const std::wstring& );
std::string FileName( const std::string& );
bool SetClipboardText( HWND, const std::wstring& );
bool SetClipboardText( HWND, const std::string& );
bool SetClipboardTextWide( HWND, const std::wstring& );
bool SetClipboardTextNarrow( HWND, const std::string& );
protected:
std::vector< std::wstring > files;
public:
// IShellExtInit
STDMETHODIMP Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY);
public:
// IContextMenu
STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO);
STDMETHODIMP GetCommandString(UINT, UINT, UINT*, LPSTR, UINT);
STDMETHODIMP QueryContextMenu(HMENU, UINT, UINT, UINT, UINT);
DECLARE_REGISTRY_RESOURCEID(IDR_CREATEHASH)
DECLARE_NOT_AGGREGATABLE(CCreateHash)
BEGIN_COM_MAP(CCreateHash)
// COM_INTERFACE_ENTRY(ICreateHash)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IShellExtInit)
COM_INTERFACE_ENTRY(IContextMenu)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct() { return S_OK; }
void FinalRelease() { }
public:
};
OBJECT_ENTRY_AUTO(__uuidof(CreateHash), CCreateHash)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.