0
我有一个读取配置文件并获取目录的C++程序。 我现在想要做的是使用配置文件中的目录设置执行.exe程序。尝试从std :: cout执行.exe
以下是一段我的代码:
int main(){
ConfigFile cfg("htbaseconfig.properties");
bool exists = cfg.keyExists("backuplocation");
exists = cfg.keyExists("logdir");
exists = cfg.keyExists("execdir");
exists = cfg.keyExists("fulldir");
exists = cfg.keyExists("incdir");
exists = cfg.keyExists("appdir");
std::string bkploc = cfg.getValueOfKey<std::string>("backuplocation");
std::cout << "Backup Location: " << bkploc << "\n";
std::string bkplogdir = cfg.getValueOfKey<std::string>("logdir");
std::cout << "Log Location: " << bkplogdir << "\n";
std::string bkpexec = cfg.getValueOfKey<std::string>("execdir");
std::cout << "Exec Directory: " << bkpexec << "\n";
std::string bkpfulldir = cfg.getValueOfKey<std::string>("fulldir");
std::cout << "Full Directory: " << bkpfulldir << "\n";
std::string bkpappdir = cfg.getValueOfKey<std::string>("appdir");
std::cout << "Real app Directory: " << bkpappdir << "\n\n\n";
for(; ;) {
Sleep(6000);
ShellExecute(NULL, L"open", , L"C:\\teste.htm", NULL,SW_SHOWNORMAL);
}
std::cin.get();
return (0);}
给ShellExecute里面,我想执行以下行解析配置选项:
$execdir/program.exe $logdir/log.txt $bkpappdir $bkploc
我该怎么办呢?我想用我在std::cout
上得到的变量来执行我的程序。
'的std :: string's级联,解析它们(或它们是如何解析的),虽然你因为你真的需要使用'std :: wstring's,所以会遇到麻烦。 –