Tuesday, 15 September 2015

c++ - Program stop to running when calls a process -


I am trying to create a program that calls another process using CreateProcess. After some problems, I change my program to open just one known program:

  if (! CreateProcess (LPWSTR) "C: \\ Program Files \ Opera \\ Opera Exe ", // a module name (use command line), // command line zero, // process handle inheritable faucet, // thread handle inherentable FALSE, // set handle inherited FALSE 0, // No creation Flag Taps, // Parents use the Environmental block, tap, // Parents start Use directory; // pointer to STARTUPINFO structure and pi) // pointer in PROCESS_INFORMATION structure.  

I have found this example in MSDN, but every The times when I run my program, windows (Vista) shows an error msg: the program is running ...

Do anyone know what the problem is?

Regards, Lindro Lima

This line is incorrect:

< Pre> (LPWSTR) "C: \\ Program Files \ Opera Opera \\ Opera.exe"

LPWBost wchar_t * has been typed. Then you are putting a simple string (the array of characters that will decay for the const char * ) in wchar_t * . The probability of the end result is not even finished

Use either CreateProcessA and leave artists, or use a broad string:

  L: C: \ \ Program Files \ Opera Opera \\ Opera.exe ",  

1 comment: