用于创建文件夹用的头文件,并且应该先加载库 imagehlp.lib
#ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CInitFile::CInitFile() { m_sFileName = ""; } CInitFile::~CInitFile() { } /***************************************************************** ** 函数名称: SetFileName() ** 输入参数: 保存文件的文件夹名 NewFolderName,保存的文件名 FileName ** 输出: 返回文件的详细路径,包括创建的文件夹 ** 函数功能: 设置文件夹名和文件名 ** 创建人:
6
** Version : 1.01 修改:张步阳 2011.6.22 ******************************************************************/ CString CInitFile::SetFileName(CString NewFolderName,CString FileName) { GetModulePath(); if (NewFolderName=="") { m_strFileParaPath=m_strFileParaPath+"\\"; } else { m_strFileParaPath=m_strFileParaPath+"\\"+NewFolderName+"\\"; } BOOL bRet=MakeSureDirectoryPathExists(m_strFileParaPath); //如果文件夹不存在,创建 文件夹 ASSERT(bRet); if (FileName=="") { m_sFileName = m_strFileParaPath; } else { m_sFileName =m_strFileParaPath+FileName; } bRet=MakeSureDirectoryPathExists(m_sFileName); ASSERT(bRet); return m_sFileName; } /***************************************************************** ** 函数名称: SetFileName() ** 输入参数: 保存文件的文件夹名或文件名 FileNameorNewFolderName ** 输出: 返回文件的详细路径 ** 函数功能: 设置文件夹名或文件名 ** 创建人: ** Version : 1.01 修改:张步阳 2011.6.22 ******************************************************************/ CString CInitFile::SetFileName(CString FileNameorNewFolderName) { GetModulePath(); if (0 < FileNameorNewFolderName.Find(".", 0))// 如果传给形参的是文件名 { m_sFileName=m_strFileParaPath+"\\"+FileNameorNewFolderName; }
7
else//如果传给形参的是文件夹名 { m_sFileName=m_strFileParaPath+"\\"+FileNameorNewFolderName+"\\"; } BOOL bRet=MakeSureDirectoryPathExists(m_sFileName); //如果文件夹或文件不存在,则 创建 ASSERT(bRet); return m_sFileName; } /***************************************************************** ** 函数名称: SetInt() ** 输入参数: Section --系统配置
文件还是各模块参数 Item --要修改的参数名 Value --要修改的参数值 ** 输出: 无 ** 函数功能: 修改配置文件中相应字段(整型)的值 ** 创建人: ** Version : 1.01 修改:张步阳 2011.6.22 ******************************************************************/ BOOL CInitFile::SetInt(CString Section, CString Item, int Value) { CString strtemp; strtemp.Format("%d", Value); WriteFileString(Section, Item, strtemp); return TRUE; } /***************************************************************** ** 函数名称: SetString() ** 输入参数: Section --系统配置文件还是各模块参数 Item --要修改的参数名 Value --要修改的参数值 ** 输出: 无 ** 函数功能: 修改配置文件中相应字段(字符串)的值 ** 创建人: ** Version : 1.01 修改:张步阳 2011.6.22 ******************************************************************/ BOOL CInitFile::SetString(CString Section, CString Item, CString Value) { WriteFileString(Section, Item, Value); return TRUE;
8
} /**********************