📄 readme.wzd
字号:
/////////////////////////////////////////////////////////////////////
// Example file.
/////////////////////////////////////////////////////////////////////
WzdPrjct.h -- an include file that defines a project's registry keys
/////////////////////////////////////////////////////////////////////
// Modify the Application Class.
/////////////////////////////////////////////////////////////////////
// 1) locate the SetRegistryKey() function and change argument to company key
// (failure to do this will cause your application's options to be saved to
// a .ini file in your system's os directory)
SetRegistryKey(COMPANY_KEY);
/////////////////////////////////////////////////////////////////////
// Modify the Mainframe Class.
/////////////////////////////////////////////////////////////////////
// 1) at start of OnCreate(), call a LoadOptions() helper function
LoadOptions1();
// 2) in OnClose(), call a SaveOptions() helper function
void CMainFrame::OnClose()
{
SaveOptions1();
CMDIFrameWnd::OnClose();
}
/////////////////////////////////////////////////////////////////////
// if GetProfileBinary()/WriteProfileBinary() are supported in your version of MFC
/////////////////////////////////////////////////////////////////////
void CMainFrame::LoadOptions1()
{
// 1) to load string options
m_sOption1=AfxGetApp()->GetProfileString(SETTINGS_KEY,OPTION1_KEY,"Default");
// 2) to load integer options
m_nOption2=AfxGetApp()->GetProfileInt(SETTINGS_KEY,OPTION2_KEY, 3 );
// 3) to load binary options
BYTE *p;
UINT size;
m_dOption3=33.3;
if (AfxGetApp()->GetProfileBinary(SETTINGS_KEY,OPTION3_KEY, &p, &size ))
{
memcpy(&m_dOption3,p,size);
delete []p;
}
}
void CMainFrame::SaveOptions1()
{
// 4) to save string options
AfxGetApp()->WriteProfileString(SETTINGS_KEY,OPTION1_KEY,m_sOption1);
// 5) to save integer options
AfxGetApp()->WriteProfileInt(SETTINGS_KEY,OPTION2_KEY, m_nOption2 );
// 6) to save binary options
AfxGetApp()->WriteProfileBinary(SETTINGS_KEY, OPTION3_KEY, (BYTE*)&m_dOption3, sizeof(m_dOption3));
}
/////////////////////////////////////////////////////////////////////
// if GetProfileBinary()/WriteProfileBinary() are NOT supported on your version of MFC
/////////////////////////////////////////////////////////////////////
void CMainFrame::LoadOptions2()
{
HKEY key;
DWORD size, type;
if(RegOpenKeyEx( HKEY_CURRENT_USER,APPLICATION_KEY,0,KEY_READ,&key) == ERROR_SUCCESS )
{
// 1) to load string options
size=128;
type = REG_SZ;
LPSTR psz = m_sOption1.GetBuffer(size);
RegQueryValueEx( key,OPTION1_KEY,0,&type,(LPBYTE)psz,&size );
m_sOption1.ReleaseBuffer();
// 2) to load integer options
size=4;
type = REG_DWORD;
RegQueryValueEx( key,OPTION2_KEY,0,&type,(LPBYTE)&m_nOption2,&size );
// 3) to load binary options
size=sizeof(DOUBLE);
type = REG_BINARY;
RegQueryValueEx( key,OPTION3_KEY,0,&type,(LPBYTE)&m_dOption3,&size );
RegCloseKey( key );
}
}
void CMainFrame::SaveOptions2()
{
HKEY key;
DWORD size, type, disposition;
if (RegOpenKeyEx( HKEY_CURRENT_USER,APPLICATION_KEY,0,
KEY_WRITE,&key)!=ERROR_SUCCESS)
{
RegCreateKeyEx( HKEY_CURRENT_USER,APPLICATION_KEY,0,"",
REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,
&key,&disposition);
}
// 4) to save string options
type = REG_SZ;
size = m_sOption1.GetLength();
RegSetValueEx( key,OPTION1_KEY,0,type,(LPBYTE)LPCSTR(m_sOption1),size );
// 5) to save int options
type = REG_DWORD;
size = 4;
RegSetValueEx( key,OPTION2_KEY,0,type,(LPBYTE)&m_nOption2,size );
// 6) to save binary options
type = REG_BINARY;
size = sizeof(DOUBLE);
RegSetValueEx( key,OPTION3_KEY,0,type,(LPBYTE)&m_dOption3,size );
RegCloseKey( key );
}
/////////////////////////////////////////////////////////////////////
// From: Visual C++ MFC Programming by Example by John E. Swanke
// Copyright (C) 1998 jeswanke. All rights reserved.
/////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -