📄 setdwordvalue.cpp
字号:
// SetDWORDValue.cpp : implementation file
//
#include "stdafx.h"
#include "RegEdit.h"
#include "SetDWORDValue.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetDWORDValue dialog
CSetDWORDValue::CSetDWORDValue(CWnd* pParent /*=NULL*/)
: CDialog(CSetDWORDValue::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetDWORDValue)
m_Name = _T("");
m_strValue = _T("");
//}}AFX_DATA_INIT
}
void CSetDWORDValue::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetDWORDValue)
DDX_Text(pDX, IDC_EDIT_NAME, m_Name);
DDX_Text(pDX, IDC_EDIT_VALUE, m_strValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetDWORDValue, CDialog)
//{{AFX_MSG_MAP(CSetDWORDValue)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetDWORDValue message handlers
void CSetDWORDValue::Disp(HKEY hKey, CString strName, CString strValue)
{
h_Key=hKey;
m_Name=strName;
m_strValue=strValue.Left(10);
CDialog::DoModal ();
}
BOOL CSetDWORDValue::OnInitDialog()
{
CDialog::OnInitDialog();
CheckDlgButton(IDC_RADIO1,BST_CHECKED);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSetDWORDValue::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
// memset(TempBuffer,0,sizeof(TCHAR));
// wcscpy(TempBuffer,(LPCTSTR)m_strValue);
if(m_strValue.Left(2)==_T("0x"))
swscanf((LPCTSTR)m_strValue,_T("%x"),&m_dwValue);
else
swscanf((LPCTSTR)m_strValue,_T("%l"),&m_dwValue);
if(ERROR_SUCCESS!=RegSetValueEx(h_Key,(LPCTSTR)m_Name,NULL, REG_DWORD,(BYTE *)&m_dwValue,sizeof(m_dwValue)))
MessageBox(_T("设置值失败!"),_T("失败"),MB_OK);
CDialog::OnOK();
}
void CSetDWORDValue::OnRadio1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(IsDlgButtonChecked(IDC_RADIO1)==BST_CHECKED)
{
if(m_strValue.Left(2)==_T("0x"))
swscanf((LPCTSTR)m_strValue,_T("%x"),&m_dwValue);
else
swscanf((LPCTSTR)m_strValue,_T("%lu"),&m_dwValue);
m_strValue.Format (_T("%x"),m_dwValue);
while(m_strValue.GetLength ()<8)
m_strValue=_T("0")+m_strValue;
m_strValue=_T("0x")+m_strValue;
UpdateData(FALSE);
}
}
void CSetDWORDValue::OnRadio2()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(IsDlgButtonChecked(IDC_RADIO2)==BST_CHECKED)
{
if(m_strValue.Left(2)==_T("0x"))
swscanf((LPCTSTR)m_strValue,_T("%x"),&m_dwValue);
else
swscanf((LPCTSTR)m_strValue,_T("%lu"),&m_dwValue);
m_strValue.Format (_T("%u"),m_dwValue);
}
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -