SetAppID()

标识程序的ID,操作系统会把同一个ID的软件在任务栏出现的位置为同一位置。

InitCommonControlsEx()

初始化控件库,否则无法使用各种控件。

OLE Initialization

默认MFC支持ActiveX控件,可以在创建软件时取消该支持。如果支持ActiveX控件的话,VS会自动添加如下OLE初始化代码。

// Initialize OLE libraries
if (!AfxOleInit())
{
	AfxMessageBox(IDP_OLE_INIT_FAILED);
	return FALSE;
}

AfxEnableControlContainer();

日志文件夹

SetRegistryKey

通过SetRegistryKey函数,可以把配置文件从ini文件中重定位到注册表中,注册表位置为:HKEY_CURRENT_USER\Software<company name><application name><section name><value name>. 如果SetRegistryKey的参数为空字符串,此时将没有层级,注册表的位置为:HKEY_CURRENT_USER\Software\\<section name>\

SetRegistryKey(_T("MichaelTest"));
WriteProfileString(_T("section"), _T("val1"), _T("xsdf"));
WriteProfileInt(_T("section"), _T("val2"), 10);

日志文件夹

GetProfileInt, GetProfileString, WriteProfileInt, and WriteProfileString

Call this member function to retrieve the string associated with an entry within the specified section in the application’s registry or .INI file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory.

free((void*)m_pszProfileName);
this->m_pszProfileName = _tcsdup(_T("C://Users//CNMIZHU7//Source//repos//MFCApplication1//x64//Debug//Project3.INI")); //绝对地址

free((void*)m_pszProfileName);
this->m_pszProfileName = _tcsdup(_T("./Project3.INI")); //相对地址,当前工作目录的Project3.INI文件

free((void*)m_pszProfileName);
this->m_pszProfileName = _tcsdup(_T("Project3.INI"));

CString y = this->GetProfileString(_T("Mail"), _T("MAPI"), _T("Michael")); //当只有文件名时,搜索路径为C:\Windows\Project3.INI,非当前目录的文件。