Code:
DWORD WINAPI thread_function(LPVOID lpParam)
{
TCHAR *t;
int command_line_out = 100;
tests_line *test = (tests_line*)lpParam;
char command_line[MAX_LINE_LEN];
TCHAR *fixed_exe_line[MAX_LINE_LEN];
//connect_file_name_and_args(test, &command_line); // creating the command line "text1.exe hello"
//printf("\n%s\n", command_line);
*fixed_exe_line = _T("\"C:\\Users\\sagic\\Desktop\\Example1 test1.exe\" hello");
STARTUPINFO start_info ;
PROCESS_INFORMATION process_info ;
ZeroMemory(&start_info, sizeof(STARTUPINFO));
ZeroMemory(&process_info, sizeof(PROCESS_INFORMATION));
DWORD wait_code;
if( !CreateProcess(NULL,fixed_exe_line , NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &start_info, &process_info))
{
printf("%d", GetLastError());
printf("create process failed");
return ERROR;
}
wait_code = WaitForSingleObject(process_info.hProcess,INFINITE);
if (WAIT_OBJECT_0 != wait_code)
{
printf("Error when waiting\n");
return ERROR;
}
CloseHandle(process_info.hThread);
CloseHandle(process_info.hProcess);
}
i want to add that if i run the process outside the thread function it does run test1.exe.