获得主程序所在路径并建立配置文件

来源:互联网 发布:能源计量数据管理制度 编辑:程序博客网 时间:2024/06/01 14:58

char sDir[100];
GetModuleFileName(NULL, sDir, 100);  // 获得配置文件的路径
CString strFile;
strFile.Format("%s", sDir);
int iFinder = strFile.ReverseFind('//');

if (iFinder > 0)
{
strFile = strFile.Left(iFinder+1);
strFile += "text.ini";
}

// 写数据
WritePrivateProfileString(section name, key name, string to add, strFile); 

原创粉丝点击