visual c++ - How to Create a process in c++ to execute exe? -


I have an exe excecute which is available in some drives. How can I use this C ++?

I am doing this way

  #include & lt; Stdio.h & gt; # Include & lt; Conio.h & gt; #include & lt; Windows.h & gt; Zero main () {STARTUPINFO si; PROCESS_INFORMATION pi; Xeromamari (and, shape (SI)); Si.cb = Size (C); Ziromori (and p, size (pi)); If (CreateProcess (L "c: \\ DOTNET.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, & SI, and PI)) {printf ("Create process failed (% d) N ", GetLastError ()); } Other {printf ("metaphor building success"); } Waiting Singing Object (pi.hProcess, INFINITE); CloseHandle (pi.hProcess); CloseHandle (pi.hThread); Getch (); }  

But each time with this error message 2 the process creation failed (i.e. the specified path can not be found) but i dotnet Exe to place only on c: \ DOTNET.exe.

Anyone suggesting what is wrong with the above code.can ...

Any help is greatly appreciated ..

Thabs Advance

I have just tested your code and it is working here:

  if (! CreateProcess (L! C: \ Program Files \) Mozilla Firefox \\ firefox.exe ", zero, zero, zero, lie, 0, zero, zero, and s, and p) )  

A C ++ / Win32 solution for your C / Windows 32 code :)

  zero ExecuteAndWait (wstring toto) {STARTUPINFO C = {Sizeof (C)}; for PROCESS_INFORMATION pi; vector & lt; TCHAR & gt; V (toto.length () + 1); (int i = 0; i & lt; toto.length () ; I ++) V [i] = toto [i]; Create process (NULL, and V [0], 0, 0, FALSE, 0, 0, 0, and pi); WaitforceSineleject (PI. Process, Exclusive); CloseHandle (pi.hProcess); CloseHandle (pi.hThread) ;}  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -