Click here to Skip to main content
15,896,557 members
Articles / Programming Languages / C++

Middle Mouse Button (or Wheel) to Doubleclick (VC6)

Rate me:
Please Sign up or sign in to vote.
4.67/5 (17 votes)
26 Jul 2010CPOL2 min read 84.2K   2K   34  
This is a small but handy tool I'm using every day. It converts a middle mouse button click in to a left mouse button double click.
// WinStartup.cpp: implementation of the CWinStartup class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "WinStartup.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

const TCHAR KEY_STARTUP[] = { _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") };



CWinStartup::CWinStartup()
{

}

CWinStartup::~CWinStartup()
{

}

bool CWinStartup::Check4App(HINSTANCE hInst, LPCTSTR lpszName, StartupUser user){
	TCHAR szPath[MAX_PATH];
	GetCurrentAppPath(hInst, szPath, sizeof(szPath));
	return Check4App(lpszName, szPath, user);
}

bool CWinStartup::Check4App(LPCTSTR lpszName, LPCTSTR lpszPath, StartupUser user){
	//CRegistry reg;
	//reg.VerifyValue(
	HKEY hRootKey;

	if (user == CurrentUser)
	{
		hRootKey = HKEY_CURRENT_USER;
	}
	else
	{
		//hRootKey = HKEY_LOCAL_MACHINE;
		hRootKey = HKEY_CURRENT_USER;
	}

	HKEY hKey = 0;
	HRESULT hr = RegOpenKey(hRootKey, KEY_STARTUP, &hKey);

	if (hr == ERROR_SUCCESS)
	{
		hr = RegQueryValueEx(hKey, lpszName, NULL,
		NULL, NULL, NULL);

		//hr = RegEnumValue(QueryValue(hKey, lpszName, 0, REG_SZ, (const BYTE*)lpszPath, strlen(lpszPath));

		RegCloseKey(hKey);
	}

	return (hr == ERROR_SUCCESS);
}


bool CWinStartup::AddApp(HINSTANCE hInst, LPCTSTR lpszName, StartupUser user)
{
	TCHAR szPath[MAX_PATH];
	GetCurrentAppPath(hInst, szPath, sizeof(szPath));

	return AddApp(lpszName, szPath, user);
}


bool CWinStartup::AddApp(LPCTSTR lpszName, LPCTSTR lpszPath, StartupUser user)
{
	HKEY hRootKey;

	if (user == CurrentUser)
	{
		hRootKey = HKEY_CURRENT_USER;
	}
	else
	{
		//hRootKey = HKEY_LOCAL_MACHINE;
		hRootKey = HKEY_CURRENT_USER;
	}

	HKEY hKey = 0;
	HRESULT hr = RegOpenKey(hRootKey, KEY_STARTUP, &hKey);

	if (hr == ERROR_SUCCESS)
	{
		hr = RegSetValueEx(hKey, lpszName, 0, REG_SZ, (const BYTE*)lpszPath, strlen(lpszPath));

		RegCloseKey(hKey);
	}

	return (hr == ERROR_SUCCESS);
}

bool CWinStartup::RemoveApp(LPCTSTR lpszName, StartupUser user)
{
	HKEY hRootKey;

	if (user == CurrentUser)
	{
		hRootKey = HKEY_CURRENT_USER;
	}
	else
	{
		//hRootKey = HKEY_LOCAL_MACHINE;
		hRootKey = HKEY_CURRENT_USER;
	}

	HKEY hKey = 0;
	HRESULT hr = RegOpenKey(hRootKey, KEY_STARTUP, &hKey);

	if (hr == ERROR_SUCCESS)
	{
		hr = RegDeleteValue(hKey, lpszName);

		RegCloseKey(hKey);
	}

	return (hr == ERROR_SUCCESS);
}

LPCTSTR CWinStartup::GetCurrentAppPath(HINSTANCE hInst, LPTSTR lpszPath, int nSize)
{
	GetModuleFileName(hInst, lpszPath, nSize);

	return lpszPath;
}

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 Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Switzerland Switzerland
programmer and software junkie since 1991 zurich switzerland

Comments and Discussions