2011-09-18 2 views
0

config 파일을 읽고 디렉토리를 얻는 C++ 프로그램이 있습니다. 지금하고 싶은 것은 설정 파일의 디렉토리 설정을 사용하여 .exe 프로그램을 실행하는 것입니다. 에서 ShellExecute 내부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);} 

, 나는 설정 옵션을 구문 분석 다음 줄을 실행하고 싶었 : :이 어떻게해야합니까

$execdir/program.exe $logdir/log.txt $bkpappdir $bkploc 

을 여기

내 코드의 조각인가? 내가 가진 변수를 가진 프로그램을 실행하고 싶습니다 std::cout.

+0

'표준 : string's가 연결될 수있는 다른 EXE 파일에서 구문 분석 (또는 구문 분석하는 방법) 방법에 따라 달라집니다 'std :: wstring's로 작업해야한다는 점에서 문제가 생길 것입니다. –

답변

1

두 번째 NULL 대신 명령 줄에 전달하는 것처럼 모든 매개 변수가 포함 된 문자열 (c 문자열, char [])을 ShellExecute에 전달해야합니다.

ShellExecute(NULL, L"open", , L"C:\\teste.htm", "option=param option2=param2",SW_SHOWNORMAL); 

같은

그래서 것인가 뭔가는하지만, 당신이

관련 문제