⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfcmd5calculatordlg.h

📁 利用Windows API来计算MD5的MFC例程.计算MD5时主要用到了CryptAcquireContext、CryptCreateHash两个API
💻 H
字号:
//*****************************************************************************
// FILE: MfcMD5CalculatorDlg.h
// DESC: Header file of MD5 calculator main dialog box.
//
// By Giovanni Dicanio <giovanni.dicanio@gmail.com>
// 2008, September 26th
//*****************************************************************************


#pragma once
#include "afxwin.h"
#include "afxcmn.h"


// forward declaration
struct MD5CalculationStatus; 


///////////////////////////////////////////////////////////////////////////////
// CMfcMD5CalculatorDlg dialog
///////////////////////////////////////////////////////////////////////////////
class CMfcMD5CalculatorDlg : public CDialog
{
// Construction
public:
	CMfcMD5CalculatorDlg(CWnd* pParent = NULL);	// standard constructor
    virtual ~CMfcMD5CalculatorDlg();

// Dialog Data
	enum { IDD = IDD_MFCMD5CALCULATOR_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:

    //------------------------------------------------------------------------
    //                              DATA MEMBERS
    //------------------------------------------------------------------------

    HICON m_hIcon;

    // Filename of input file to calculate MD5
    CString m_inputFileName;

    // Should the MD5 computation stop?
    // Set this flag to TRUE to stop MD5 calculation worker thread.
    BOOL m_stopMD5Calculation;

    // Status of MD5 Calculation 
    // (exists only during worker thread execution)
    MD5CalculationStatus * m_calcStatus;


    //------------------------------------------------------------------------
    //                              HELPER METHODS
    //------------------------------------------------------------------------

    // Copies a string to clipboard.
    // Returns FALSE on error.
    BOOL CopyStringToClipboard( LPCTSTR text );

    // Enables or disables buttons for copy MD5 to clipboard
    void EnableMD5Copy( BOOL enable = TRUE );

    // Enables or disables buttons for selecting input file
    void EnableFileSelection( BOOL enable = TRUE );

    // Thread function (used for background MD5 computation);
    // just routes to non-static MD5WorkerThreadFunctionMain()
    static UINT MD5WorkerThreadFunction( LPVOID param );

    // *Main* Thread function (used for background MD5 computation).
    // This is non-static, so it can access class data members
    void MD5WorkerThreadFunctionMain();


    // If the input flag is TRUE, sets the GUI in a state corresponding to MD5
    // calculation (e.g. the stop button is enabled, and other copy MD5 buttons
    // are disabled, because there is no MD5 available yet).
    // Else, the GUI is set in a state when there is no MD5 calculation running
    // (e.g. the stop button is disabled, because there is no worker thread running).
    void SetGUIStateForMD5Calculation( BOOL calculatingMD5 = TRUE );


    //------------------------------------------------------------------------
    //                          MESSAGE HANDLERS
    //------------------------------------------------------------------------

	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

    afx_msg void OnBnClickedBrowseFilename();
    afx_msg void OnBnClickedClear();
    afx_msg void OnBnClickedCalculateMD5();
    afx_msg void OnBnClickedCopyMD5();
    afx_msg void OnBnClickedCopyMD5FileTitle();
    afx_msg void OnBnClickedCopyMD5FullPath();
    afx_msg void OnBnClickedStopCalculation();
    afx_msg LRESULT OnMD5CalculationProgress( WPARAM wParam, LPARAM lParam );
    afx_msg LRESULT OnMD5CalculationTerminated( WPARAM wParam, LPARAM lParam );
    afx_msg void OnDropFiles(HDROP hDropInfo);


    //------------------------------------------------------------------------
    //                          CONTROLS
    //------------------------------------------------------------------------
    
    // Input file name (with full path)
    CEdit m_wndFilename;

    // Input file title (name without path)
    CEdit m_wndInfoFileTitle;

    // Input file path
    CEdit m_wndInfoPath;

    // MD5 digest of input file
    CEdit m_wndMD5Digest;

    // Start MD5 calculation
    CButton m_btnCalculateMD5;

    // Button to stop MD5 calculation
    CButton m_btnStop;

    // Progress bar indicating MD5 progress
    CProgressCtrl m_wndMD5Progress;

    // Status messages
    CStatic m_wndMessage;

    // Copy MD5 and file title to the clipboard
    CButton m_btnCopyMD5AndFileTitle;

    // Copy MD5 and full path to the clipboard
    CButton m_btnCopyMD5AndFilePath;

    // Copy MD5 to the clipboard
    CButton m_btnCopyMD5;

    // Select input file
    CButton m_btnBrowse;

    // Clear input file
    CButton m_btnClear;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -