configration.cpp

来自「本人买的<<VC++项目开发实例>>源代码配套光盘.」· C++ 代码 · 共 73 行

CPP
73
字号
// Configration.cpp: implementation of the CConfigration class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "WMVC.h"
#include "Configration.h"

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

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

CConfigration::CConfigration()
{
	LONG nErr = m_reg.Create(HKEY_LOCAL_MACHINE, "Software\\VCBook\\WMWB");
	if (ERROR_SUCCESS != nErr)
	{
		AfxThrowResourceException();
	}
}

CConfigration::~CConfigration()
{
	m_reg.Close();
}
//把对象中所有的成员序列化到注册表中
void CConfigration::Save()
{
	m_reg.SetValue(m_strVersion, "Version");
	m_reg.SetValue(m_dwHotKey, "HotKey");
	m_reg.SetValue(m_dwKeyboardLayout, "KeyboardLayout");
	m_reg.SetValue(m_dwStopPromptMin, "StopPromptMin");
}
//把注册表中所有的配置信息加载到对象中
void CConfigration::Load()
{
	DWORD dwCount = 256;
	CString strTemp;

	m_reg.QueryValue(strTemp.GetBuffer(dwCount), "Version", &dwCount);
	strTemp.ReleaseBuffer(-1);	
	if ("" == strTemp)
	{
		m_strVersion = "1.0";
	}
	else
	{
		m_strVersion = strTemp;
	}
	//取出KeyboardLayout
	m_reg.QueryValue(m_dwKeyboardLayout, "KeyboardLayout");
	if (0 == m_dwKeyboardLayout)
	{
		//表示不激活任何KeyboardLayout
	}

	//取出快捷键,采用的是RegisterHotkey的格式。
	m_reg.QueryValue(m_dwHotKey, "HotKey");
	if ( 0 == m_dwHotKey)
	{
		//lo-word为Virtual Key Code, hi-word为modifiers
		m_dwHotKey = MAKELONG('Q', MOD_CONTROL);
	}
	//最小化提示标志
	m_reg.QueryValue(m_dwStopPromptMin, "StopPromptMin");		
}

⌨️ 快捷键说明

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