Since you recently want to write a gtest UI test, you need to create a process and send messages to it. However, the CreateProcess function always fails at the beginning.
Test (clean_up_tests, time_table_dlg) <br/>{< br/> startupinfo sistartinfo; <br/> process_information piprocinfo; <br/> // set up members of startupinfo structure. <br/> sistartinfo. CB = sizeof (startupinfo); <br/> sistartinfo. lpreserved = NULL; <br/> sistartinfo. lpreserved2 = NULL; <br/> sistartinfo. cbreserved2 = 0; <br/> sistartinfo. lpdesktop = NULL; <br/> sistartinfo. dwflags = 0; </P> <p> // The specified line <br/> tchar sz1_line [_ max_path] = _ T ("planet.exe "); </P> <p> int ncreateresult = <br/> CreateProcess (null, szcmdline, <br/> null, null, false, 0, null, null, & sistartinfo, & piprocinfo); <br/> //...... <br/>}< br/>
I found all kinds of information, but I cannot find the reason. Bored, when I put startupinfo and process_information struct definitions outside the test () function as a global variable, the situation turned around. Does the scope of these two variables affect the function execution process? However, I have searched various usage instructions on these two variables, and I have not mentioned this point. I will post this phenomenon. If it can help people who are encountering this problem, I am very lucky.