The actual problem encountered was that I copied a piece of code from MSDN, which was written in C. The code was compiled and the execution crashed,
# Include
// Test. c uses Unicode to compile and crash void main () {STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory (& si, sizeof (si); si. cb = sizeof (si); ZeroMemory (& pi, sizeof (pi); if (! CreateProcess (NULL, // No module name (use command line) "calc.exe", // Command lineNULL, // Process handle not inheritableNULL, // Thread handle not inheritableFALSE, // Set handle inheritance to FALSE0, // No creation flagsNULL, // Use parent's environment blockNULL, // Use parent's starting directory & si, // Pointer to STARTUPINFO structure & pi) // Pointer to PROCESS_INFORMATION structure) WaitForSingleObject (pi. hProcess, INFINITE); // Close process and thread handles. closeHandle (pi. hProcess); CloseHandle (pi. hThread );}
The above code can be compiled in unicode c mode. If the code crashes during runtime, the compiler will report a warning, which is not an error.
Test. c (13): warning C4133: 'function': incompatible types-from 'Char [9] 'to 'lpwstr'
The second parameter of CreateProcessW must be LPWSTR. If it is forcibly converted and compiled in c ++ mode, an error is returned.
Test. cpp (21): error C2664: 'createprocessw': cannot convert parameter 2 from 'const char [9] 'to 'lpwstr'