📄 inirwtestdlg.cpp
字号:
// iniRWtestDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "iniRWtest.h"
#include "iniRWtestDlg.h"
#include "IniWR.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
TCHAR *lpFileName = _T("\\STORAGE CARD\\WinCE.ini"); // 文件名
TCHAR lpAppName[MAX_PATH] = _T("test"); // 段名
TCHAR lpKeyName[MAX_PATH] = _T("KB"); // 健名
TCHAR szValue[MAX_PATH] = {0}; // 键值(string)
UINT nValue = 0;
CIniWR test;
// CiniRWtestDlg 对话框
CiniRWtestDlg::CiniRWtestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CiniRWtestDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CiniRWtestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CiniRWtestDlg, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
ON_WM_SIZE()
#endif
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON1, &CiniRWtestDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &CiniRWtestDlg::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON3, &CiniRWtestDlg::OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON4, &CiniRWtestDlg::OnBnClickedButton4)
END_MESSAGE_MAP()
// CiniRWtestDlg 消息处理程序
BOOL CiniRWtestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CiniRWtestDlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
if (AfxIsDRAEnabled())
{
DRA::RelayoutDialog(
AfxGetResourceHandle(),
this->m_hWnd,
DRA::GetDisplayMode() != DRA::Portrait ?
MAKEINTRESOURCE(IDD_INIRWTEST_DIALOG_WIDE) :
MAKEINTRESOURCE(IDD_INIRWTEST_DIALOG));
}
}
#endif
void CiniRWtestDlg::OnBnClickedButton1()
{
test.GetPrivateProfileString(lpAppName,lpKeyName,NULL,szValue,DIM(szValue),lpFileName);
_tcscpy(lpKeyName,_T("DT"));
nValue = test.GetPrivateProfileInt(lpAppName,lpKeyName,1,lpFileName);
// TODO: 在此添加控件通知处理程序代码
}
void CiniRWtestDlg::OnBnClickedButton2()
{
_tcscpy(lpAppName,_T("New create section"));
_tcscpy(lpKeyName,_T("New create Key"));
_tcscpy(szValue,_T("New create Value"));
test.WritePrivateProfileString(lpAppName,lpKeyName,szValue,lpFileName);
// create a new key (the key value is a string)
_tcscpy(lpKeyName,_T("New create Key2"));
_tcscpy(szValue,_T("New create Value2"));
test.WritePrivateProfileString(lpAppName,lpKeyName,szValue,lpFileName);
// create a new key (the key value is an integer)
_tcscpy(lpKeyName,_T("New create Key3"));
nValue = 112233;
test.WritePrivateProfileInt(lpAppName,lpKeyName,nValue,lpFileName);
}
void CiniRWtestDlg::OnBnClickedButton3()
{
_tcscpy(lpKeyName,_T("New create Key2"));
_tcscpy(szValue,_T("New modified Value2"));
test.WritePrivateProfileString(lpAppName,lpKeyName,szValue,lpFileName);
_tcscpy(lpKeyName,_T("New create Key3"));
nValue = 332211;
test.WritePrivateProfileInt(lpAppName,lpKeyName,nValue,lpFileName);
}
void CiniRWtestDlg::OnBnClickedButton4()
{
_tcscpy(lpKeyName,_T("New create Key2"));
test.WritePrivateProfileString(lpAppName,lpKeyName,NULL,lpFileName);
// delete the entire section
test.WritePrivateProfileString(lpAppName,NULL,szValue,lpFileName);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -