저는 스레딩 및 프로세스에 새로운 것이므로 많은 다른 포럼 게시물이 있지만 실행 파일을 시작하기 위해 CreateProcess()를 얻을 수 없습니다. 어떻게 작동하는지에 대한 나의 빈약 한 이해에서 나는 올바른 매개 변수를 설정했다고 생각하지만 Create Process failed (267)
오류가 발생합니다. 실행하려고하는 실행 파일은 xst라고하는 Xilinx 제품군에 속하는 명령 줄 도구입니다. 내가 원하는 것은 path
전역 변수로 정의 된 디렉토리에서 xst를 실행하여 거기에 저장된 일부 파일에서 작동 할 수 있도록하는 것입니다. CreateProcess() 매개 변수가 잘못 되었습니까?CreateProcess + Call 명령 줄 도구
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <sddl.h>
#include <windows.h>
#include <AccCtrl.h>
#include <Aclapi.h>
std::string path = "C:\\FPGA\\BSP\\BSP\\Xilinx\\SingleItemTest\\";
void testXST(std::string filePath, std::string arguements) {
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
// Start the child process.
if (!CreateProcess(
LPTSTR(filePath.c_str()),
LPTSTR(arguements.c_str()),
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
LPTSTR(path.c_str()),
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
)
{
printf("CreateProcess failed (%d).\n", GetLastError());
return;
}
// Wait until child process exits.
WaitForSingleObject(pi.hProcess, INFINITE);
// Close process and thread handles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
int main()
{
std::string xstPath = "C:\\Xilinx\\14.7\\ISE_DS\\ISE\\bin\\nt\\xst.exe";
std::string args = " -h";
testXST(xstPath, args);
return 0;
}
나는 그래서 난 아무데도 명령 줄에서하지만, 올바른 문제가되지해야 실행 파일에 대한 직접 경로를 제공하고 있기 때문에 호출 할 수 있습니다 XST에 설정된 환경 변수?
'LPTSTR (filePath.c_str()),'- 왜 당신은'(LPTSTR)'을 캐스팅할까요 ?? 유니 코드 응용 프로그램을 빌드하는 경우에는이 작업이 작동하지 않습니다. 캐스트를 제거하고 컴파일러 오류가있는 경우 적절한 문자열 유형을 사용하여 오류를 수정하고 캐스팅하여 오류를 은폐하지 마십시오. – PaulMcKenzie
'std :: wstring'이 필요합니다. 문자열 리터럴 앞에'L '을 붙입니다. 그런 다음 모든 캐스트를 제거합니다. –
또한 사용중인 경우 [CreateProcess'에 대해 [documentation of] (https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx) 신중하게 읽으십시오. 유니 코드 버전. 두 번째 매개 변수는 문자열 리터럴이 아닌 쓰기 가능한 TCHAR 버퍼 여야합니다. – PaulMcKenzie