⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myinireaddlg.cpp

📁 wince evc ini读写 au1200
💻 CPP
字号:
// MYINIREADDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MYINIREAD.h"
#include "MYINIREADDlg.h"
#include "IniWR.h"

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


TCHAR *lpFileName = _T("\\Storage Card\\test.ini");                     // 文件名
TCHAR lpAppName[MAX_PATH] = _T("VIDEO");                                  // 段名
TCHAR lpKeyName[MAX_PATH] = _T("V[0]");                                    // 健名
TCHAR szValue[MAX_PATH] = {0};                                           // 键值(string)
UINT  nValue = 0; 
CIniWR test;
/////////////////////////////////////////////////////////////////////////////
// CMYINIREADDlg dialog

CMYINIREADDlg::CMYINIREADDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMYINIREADDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMYINIREADDlg)
	m_edit1 = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMYINIREADDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMYINIREADDlg)
	DDX_Text(pDX, IDC_EDIT1, m_edit1);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMYINIREADDlg, CDialog)
	//{{AFX_MSG_MAP(CMYINIREADDlg)
	ON_BN_CLICKED(IDC_OPEN, OnOpen)
	ON_BN_CLICKED(IDC_READ, OnRead)
	ON_BN_CLICKED(IDC_WRITE, OnWrite)
	ON_BN_CLICKED(IDC_MODIFY, OnModify)
	ON_BN_CLICKED(IDC_DELETE, OnDelete)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMYINIREADDlg message handlers

BOOL CMYINIREADDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CMYINIREADDlg::OnOpen() 
{
	// TODO: Add your control notification handler code here
	  CString    strFilter = _T("INI File (*.ini)|*.ini|");
                 strFilter += _T("All Files (*.*)|*.*|");
       CFileDialog dlgOpen(TRUE, NULL, NULL, OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, 
              strFilter, this);
       if (IDOK == dlgOpen.DoModal()) 
       {
              mSourceFile = dlgOpen.GetPathName();
             
       }
}

void CMYINIREADDlg::OnRead() 
{
	// TODO: Add your control notification handler code here
		test.GetPrivateProfileString(lpAppName,lpKeyName,NULL,m_edit1.GetBuffer(MAX_PATH),MAX_PATH,lpFileName);
	//nValue = test.GetPrivateProfileInt(lpAppName,lpKeyName,1,lpFileName);
    //m_edit1.Format(TEXT("%x"),nValue);
	
	
	UpdateData(false);
}



void CMYINIREADDlg::OnWrite() 
{
	// TODO: Add your control notification handler code here

	_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 CMYINIREADDlg::OnModify() 
{
	// TODO: Add your control notification handler code here
	_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 CMYINIREADDlg::OnDelete() 
{
	// TODO: Add your control notification handler code here
		_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 + -