I am really new to both C ++ and the Windows API. Today, the question suddenly arises to me whether I need to maintain a long service life of the input parameters CreateProcess. According to MSDN:
BOOL WINAPI CreateProcess(
_In_opt_ LPCTSTR lpApplicationName,
_Inout_opt_ LPTSTR lpCommandLine,
_In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
_In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
_In_ BOOL bInheritHandles,
_In_ DWORD dwCreationFlags,
_In_opt_ LPVOID lpEnvironment,
_In_opt_ LPCTSTR lpCurrentDirectory,
_In_ LPSTARTUPINFO lpStartupInfo,
_Out_ LPPROCESS_INFORMATION lpProcessInformation
);
for example, LPSTARTUPINFO lpStartupInfoa pointer pointing to a STARTUPINFO structure.
I am wondering if you need to keep the structure after it CreateProcessreturns. In addition, other Windows API functions have similar input parameters that are entered as a pointer, I don’t know if I need to save the objects pointed to by input pointers after returning the API functions.
WaitForSingleObject , , CreateProcess. CreateProcess "ExecuteProcess". CreateProcess ExecuteProcess, , , ExecuteProcess.
MSDN , , CreateProcess . CreateProcess CreateChildProcess, "CreateChildProcess" WaitForSingleObject .