setszvalue.cpp

来自「基于EVC环境下的注册表编辑功能的完整源代码」· C++ 代码 · 共 64 行

CPP
64
字号
// SetSZValue.cpp : implementation file
//

#include "stdafx.h"
#include "RegEdit.h"
#include "SetSZValue.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSetSZValue dialog


CSetSZValue::CSetSZValue(CWnd* pParent /*=NULL*/)
	: CDialog(CSetSZValue::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetSZValue)
	m_Name = _T("");
	m_Value = _T("");
	//}}AFX_DATA_INIT
}


void CSetSZValue::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetSZValue)
	DDX_Text(pDX, IDC_EDIT_NAME, m_Name);
	DDX_Text(pDX, IDC_EDIT_VALUE, m_Value);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetSZValue, CDialog)
	//{{AFX_MSG_MAP(CSetSZValue)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetSZValue message handlers

void CSetSZValue::Disp(HKEY hKey, CString strName, CString strValue)
{
	m_Name=strName;
	m_Value=strValue;
	h_Key=hKey;
	DoModal ();
}

void CSetSZValue::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	
//	MessageBox(m_Value,NULL,MB_OK);
	if(ERROR_SUCCESS!=RegSetValueEx(h_Key,(LPCTSTR)m_Name,NULL,REG_SZ,(CONST BYTE *)(LPCTSTR)m_Value,m_Value.GetLength()*2 ))
		MessageBox(_T("设置值失败!"),_T("失败"),MB_OK);
    	CDialog::OnOK();
}

⌨️ 快捷键说明

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