Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A File Checksum Shell Menu Extension DLL

, 23 May 2008 LGPL3
Create a File Checksum Shell Menu Extension using ATL and Crypto++
ctxcreatehash.zip
CtxCreateHash
CtxCreateHash
CreateHash.rgs
CtxCreateHash.def
CtxCreateHash.rgs
CtxCreateHash.vcproj.8.00.old
CtxCreateHashps.def
CtxCreateHashPS.vcproj.8.00.old
CtxCreateHash.sln.old
ctxcreatehash2005.zip
CreateHash.rgs
CtxCreateHash.aps
CtxCreateHash.def
CtxCreateHash.rgs
CtxCreateHashps.def
ctxcreatehashdll.zip
CtxCreateHash.dll
ctxverifyhash.zip
CtxVerifyHash
CtxVerifyHash
CtxVerifyHash.def
CtxVerifyHash.rgs
CtxVerifyHash.vcproj.8.00.old
CtxVerifyHashps.def
CtxVerifyHashPS.vcproj.8.00.old
VerifyHash.rgs
CtxVerifyHash.sln.old
ctxverifyhash2005.zip
CtxVerifyHash.aps
CtxVerifyHash.def
CtxVerifyHash.rgs
CtxVerifyHashps.def
VerifyHash.rgs
ctxverifyhashdll.zip
CtxVerifyHash.dll
sample1.zip
Sample 1
Test 1.dsp
Test 1.dsw
sample2.zip
Sample 2
Test 2.dsp
Test 2.dsw
sample3.zip
Sample 3
Test 3.dsp
Test 3.dsw
sample4.zip
Sample 4
Test 4.dsp
Test 4.dsw
sample5.zip
Sample 5
CtxTest.def
CtxTest.dsp
CtxTest.dsw
CtxTestps.def
CtxTestps.mk
MenuItem.rgs
// IMPLEMENTATION FOR THE CProfiler CLASS
// (c) Hernan Di Pietro 2003.
/////////////////////////////////////////////////////////////////
#include "stdafx.h"

#pragma warning(disable: 4786 )

#include <cstdio>
#include "profiler.h"

CProfiler::CProfiler(void)
{
	// constructor zeroes all LARGE_INTEGER data
	// members and gets the correct counter frequency
	// for the system.
	ZeroMemory(&m_QPFrequency, sizeof(m_QPFrequency));
	ZeroMemory(&m_ElapsedTime, sizeof(m_ElapsedTime));
	ZeroMemory(&m_StartCounter,sizeof(m_StartCounter));
	m_Retval = 0;

	// Query Frecuency
	m_Retval = QueryPerformanceFrequency(&m_QPFrequency);	
}

CProfiler::~CProfiler(void)
{
	// destructor does nothing specific...
}

/////////////////////////////////////////////////////////////
// GetLastRetVal()
// returns error code for the latest API function called
/////////////////////////////////////////////////////////////
inline DWORD CProfiler::GetLastRetVal()
{
	return static_cast<DWORD>(m_Retval);
}

/////////////////////////////////////////////////////////////
// ProfileStart
// Starts time count, specifying the debug log type
// which is written when ProfileEnd is called.
// May be LOGNONE (default), LOGTICKS, LOGSECS, LOGALL
////////////////////////////////////////////////////////////
void CProfiler::ProfileStart(LOGTYPE logtype)
{
	// get and store start time
	m_Retval = QueryPerformanceCounter (&m_StartCounter);
	// store logging type
	m_LogType = logtype;
}

/////////////////////////////////////////////////////////////
// ProfileEnd 
// End profiling and optionally write a string to the
// debug window or to a message box, depending on the
// LOGTYPE specified on ProfileStart(...)
////////////////////////////////////////////////////////////
__int64 CProfiler::ProfileEnd(char* TraceStr)
{
	// get and store finishing time and calc elapsed time(ticks)
	m_Retval = QueryPerformanceCounter (&m_EndCounter);
	m_ElapsedTime = (m_EndCounter.QuadPart  - m_StartCounter.QuadPart );

    // output debugging log?
    if (m_LogType != LOGNONE)
	{
		// variables for output
        /*
		TCHAR* MsgOut;
		TCHAR tmpbuf[300];        
		
		if (m_LogType == LOGTICKS)	// output in ticks
            _tcsprintf(tmpbuf, "** ProfileEnd: %I64d clock ticks elapsed.\n", m_ElapsedTime);

		if (m_LogType == LOGSECS)  // output in secs		
			_tsprintf(tmpbuf, "** ProfileEnd: %.3fsecs. elapsed.\n", SecsFromTicks(m_ElapsedTime)); 		

		if (m_LogType == LOGMSGBOX)
			_tsprintf(tmpbuf, "\n\n%I64d clock ticks (%.3fsecs.) elapsed.\n", 
					m_ElapsedTime, SecsFromTicks(m_ElapsedTime));

		if (m_LogType == LOGALL)
			_tsprintf(tmpbuf, "** Profile End **\n[CPU Hires counter freq is: %I64d clock ticks" 
			                "per second.\n%I64d clock ticks (%.3fsecs.) elapsed.\n", 
							m_QPFrequency.QuadPart ,m_ElapsedTime, SecsFromTicks(m_ElapsedTime)); 

		MsgOut = new TCHAR[strlen(tmpbuf)+strlen(TraceStr)+1];
		strcpy (MsgOut, TraceStr);
		strcat (MsgOut, tmpbuf);

		// select output to msgbox or debug-results window
		if (m_LogType == LOGMSGBOX)
		{
            MessageBox (NULL, MsgOut, _T("CProfiler::ProfileEnd Timing"), 
						MB_ICONINFORMATION | MB_OK);
		}
		else
		{
			OutputDebugString(MsgOut);
		}

		delete [] MsgOut;
            */
	}
	return m_ElapsedTime;
}

// The following function convert ticks to seconds
double CProfiler::SecsFromTicks (__int64 ticks)
{
	return static_cast<double>(ticks) / static_cast<double>(m_QPFrequency.QuadPart);
}

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.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

Share

About the Author

Jeffrey Walton
Systems / Hardware Administrator
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150123.1 | Last Updated 24 May 2008
Article Copyright 2006 by Jeffrey Walton
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid