1

我正在使用 Codegear C++ 开发表单应用程序。代码中的所有 Exe 名称都是硬编码的。Exes 存在于一个公共驱动器中。删除硬编码的最佳方法是什么?使用 .ini 文件好吗?如果是,该怎么做?我尝试使用 .ini 文件,如下所示,但它不起作用:

settings.ini 文件:

[路径设置]
exe1="R:\\exe1"    
exe2="R:\\exe2"
exe3="R:\\exe3"

在我添加的代码中:

#define PATH_INI "settings.ini"      //.ini in the same folder

获取exes的路径

GetPrivateProfileString("PathSettings", "exe1", "", pathExe, 1000, PATH_INI);
//to get the exe1 path into pathExe 

GetPrivateProfileString("PathSettings", "exe2", "", pathExe, 1000, PATH_INI);
//to get the exe2 path into pathExe
4

0 回答 0