+/**
+ * Create the process with WCHAR API
+ */
+static BOOL
+CreateChildProcessW(const char *comspec, const char *cmdLine,
+ PROCESS_INFORMATION *hProcInfo,
+ HANDLE in, HANDLE out, HANDLE err)
+{
+ STARTUPINFOW siStartInfo;
+ BOOL bFuncRetn = FALSE;
+
+ // Set up members of the STARTUPINFO structure.
+ ZeroMemory( &siStartInfo, sizeof(siStartInfo) );
+ siStartInfo.cb = sizeof(siStartInfo);
+ // setup new process to use supplied handles for stdin,stdout,stderr
+
+ siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+ siStartInfo.wShowWindow = SW_SHOWMINNOACTIVE;
+
+ siStartInfo.hStdInput = in;
+ siStartInfo.hStdOutput = out;
+ siStartInfo.hStdError = err;
+
+ // Convert argument to WCHAR
+ POOLMEM *cmdLine_wchar = get_pool_memory(PM_FNAME);
+ POOLMEM *comspec_wchar = get_pool_memory(PM_FNAME);
+
+ UTF8_2_wchar(&cmdLine_wchar, cmdLine);
+ UTF8_2_wchar(&comspec_wchar, comspec);
+
+ // Create the child process.
+ Dmsg2(dbglvl, "Calling CreateProcess(%s, %s, ...)\n", comspec_wchar, cmdLine_wchar);
+
+ // try to execute program
+ bFuncRetn = p_CreateProcessW((WCHAR*)comspec_wchar,
+ (WCHAR*)cmdLine_wchar,// command line
+ NULL, // process security attributes
+ NULL, // primary thread security attributes
+ TRUE, // handles are inherited
+ 0, // creation flags
+ NULL, // use parent's environment
+ NULL, // use parent's current directory
+ &siStartInfo, // STARTUPINFO pointer
+ hProcInfo); // receives PROCESS_INFORMATION
+ free_pool_memory(cmdLine_wchar);
+ free_pool_memory(comspec_wchar);
+
+ return bFuncRetn;
+}
+
+
+/**
+ * Create the process with ANSI API
+ */
+static BOOL
+CreateChildProcessA(const char *comspec, char *cmdLine,
+ PROCESS_INFORMATION *hProcInfo,
+ HANDLE in, HANDLE out, HANDLE err)
+{
+ STARTUPINFOA siStartInfo;
+ BOOL bFuncRetn = FALSE;
+
+ // Set up members of the STARTUPINFO structure.
+ ZeroMemory( &siStartInfo, sizeof(siStartInfo) );
+ siStartInfo.cb = sizeof(siStartInfo);
+ // setup new process to use supplied handles for stdin,stdout,stderr
+ siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+ siStartInfo.wShowWindow = SW_SHOWMINNOACTIVE;
+
+ siStartInfo.hStdInput = in;
+ siStartInfo.hStdOutput = out;
+ siStartInfo.hStdError = err;
+
+ // Create the child process.
+ Dmsg2(dbglvl, "Calling CreateProcess(%s, %s, ...)\n", comspec, cmdLine);
+
+ // try to execute program
+ bFuncRetn = p_CreateProcessA(comspec,
+ cmdLine, // command line
+ NULL, // process security attributes
+ NULL, // primary thread security attributes
+ TRUE, // handles are inherited
+ 0, // creation flags
+ NULL, // use parent's environment
+ NULL, // use parent's current directory
+ &siStartInfo,// STARTUPINFO pointer
+ hProcInfo);// receives PROCESS_INFORMATION
+ return bFuncRetn;
+}
+