这篇教程C++ CreateProcessW函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CreateProcessW函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateProcessW函数的具体用法?C++ CreateProcessW怎么用?C++ CreateProcessW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CreateProcessW函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: procRunenum procerrprocRun(unsigned xnargs, char * const xargs[], int * rc){ STARTUPINFOW si; PROCESS_INFORMATION pi; enum procerr err = ERR_PROC_OK; DWORD drc = 0; WCHAR args[MAXCMD]; LPWSTR cl = GetCommandLineW(); int argc; LPWSTR * wargv = CommandLineToArgvW(cl, &argc); argvToCommandLine(args, argc-4, wargv+4); LocalFree(wargv); memset(&si, 0, sizeof(si)); si.cb = sizeof(si); CHK(ERR_PROC_FORK, !CreateProcessW(0, args, 0, 0, 0, CREATE_SUSPENDED, 0, 0, &si, &pi)); if (err == ERR_PROC_OK) injectProcess(pi.hProcess); CHK(ERR_PROC_EXEC, -1 == ResumeThread(pi.hThread)); CHK(ERR_PROC_WAIT, WAIT_OBJECT_0 != WaitForSingleObject(pi.hThread, INFINITE)); CHK(ERR_PROC_WAIT, WAIT_OBJECT_0 != WaitForSingleObject(pi.hProcess, INFINITE)); CHK(ERR_PROC_WAIT, !GetExitCodeProcess(pi.hProcess, &drc)); CHK(ERR_PROC_FORK, !CloseHandle(pi.hThread)); CHK(ERR_PROC_FORK, !CloseHandle(pi.hProcess)); if (err == ERR_PROC_OK) *rc = drc; return err;}
开发者ID:jacereda,项目名称:fsatrace,代码行数:28,
示例2: __declspec//Called before StarCraft is completely loadedextern "C" __declspec(dllexport) bool ApplyPatchSuspended(HANDLE, DWORD){ if (GetFileAttributesW(WLAUNCHER) == 0xFFFFFFFF) { MessageBoxW(NULL, L"wLauncher.exe not found!", L"wDetector Plugin", MB_OK | MB_ICONERROR); return false; } if (GetFileAttributesW(WDETECTOR) == 0xFFFFFFFF) { MessageBoxW(NULL, L"wDetector.w not found!", L"wDetector Plugin", MB_OK | MB_ICONERROR); return false; } if (wcscmp(FileVersion(WDETECTOR), L"3.37") != 0) { MessageBoxW(NULL, L"wDetector's version is incorrect!", L"wDetector Plugin", MB_OK | MB_ICONERROR); return false; } STARTUPINFOW info = { sizeof(info) }; if (!CreateProcessW(WLAUNCHER, NULL, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo)) { MessageBoxW(NULL, L"Failed to start wLauncher.exe!", L"wDetector Plugin", MB_OK | MB_ICONERROR); return false; } return true;}
开发者ID:Danteoriginal,项目名称:wDetectorPlugin,代码行数:31,
示例3: runCmd/** * This function runs the specified command in the specified dir. * [in,out] cmdline - the command line to run. The function may change the passed buffer. * [in] dir - the dir to run the command in. If it is NULL, then the current dir is used. * [in] wait - whether to wait for the run program to finish before returning. * [in] minimized - Whether to ask the program to run minimized. * * Returns: * If running the process failed, returns INVALID_RUNCMD_RETURN. Use GetLastError to get the error code. * If wait is FALSE - returns 0 if successful. * If wait is TRUE - returns the program's return value. */static int runCmd(LPWSTR cmdline, LPCWSTR dir, BOOL wait, BOOL minimized){ STARTUPINFOW si; PROCESS_INFORMATION info; DWORD exit_code=0; memset(&si, 0, sizeof(si)); si.cb=sizeof(si); if (minimized) { si.dwFlags=STARTF_USESHOWWINDOW; si.wShowWindow=SW_MINIMIZE; } memset(&info, 0, sizeof(info)); if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, dir, &si, &info)) { printf("Failed to run command (%ld)/n", GetLastError()); return INVALID_RUNCMD_RETURN; } printf("Successfully ran command/n"); //%s - Created process handle %p/n", //wine_dbgstr_w(cmdline), info.hProcess); if (wait) { /* wait for the process to exit */ WaitForSingleObject(info.hProcess, INFINITE); GetExitCodeProcess(info.hProcess, &exit_code); } CloseHandle(info.hProcess); return exit_code;}
开发者ID:svn2github,项目名称:ros-explorer,代码行数:47,
示例4: start_rpcssstatic BOOL start_rpcss(void){ PROCESS_INFORMATION pi; STARTUPINFOW si; WCHAR cmd[MAX_PATH]; static const WCHAR rpcss[] = {'//','r','p','c','s','s','.','e','x','e',0}; BOOL rslt; void *redir; TRACE("/n"); ZeroMemory(&si, sizeof(STARTUPINFOA)); si.cb = sizeof(STARTUPINFOA); GetSystemDirectoryW( cmd, MAX_PATH - sizeof(rpcss)/sizeof(WCHAR) ); strcatW( cmd, rpcss ); Wow64DisableWow64FsRedirection( &redir ); rslt = CreateProcessW( cmd, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ); Wow64RevertWow64FsRedirection( redir ); if (rslt) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); Sleep(100); } return rslt;}
开发者ID:bilboed,项目名称:wine,代码行数:29,
示例5: openvpn_execve/* * Attempt to simulate fork/execve on Windows */intopenvpn_execve (const struct argv *a, const struct env_set *es, const unsigned int flags){ int ret = -1; static bool exec_warn = false; if (a && a->argv[0]) { if (openvpn_execve_allowed (flags)) { struct gc_arena gc = gc_new (); STARTUPINFOW start_info; PROCESS_INFORMATION proc_info; char *env = env_block (es); WCHAR *cl = wide_cmd_line (a, &gc); WCHAR *cmd = wide_string (a->argv[0], &gc); CLEAR (start_info); CLEAR (proc_info); /* fill in STARTUPINFO struct */ GetStartupInfoW(&start_info); start_info.cb = sizeof(start_info); start_info.dwFlags = STARTF_USESHOWWINDOW; start_info.wShowWindow = SW_HIDE; /* this allows console programs to run, and is ignored otherwise */ DWORD proc_flags = CREATE_NO_WINDOW; if (CreateProcessW (cmd, cl, NULL, NULL, FALSE, proc_flags, env, NULL, &start_info, &proc_info)) { DWORD exit_status = 0; CloseHandle (proc_info.hThread); WaitForSingleObject (proc_info.hProcess, INFINITE); if (GetExitCodeProcess (proc_info.hProcess, &exit_status)) ret = (int)exit_status; else msg (M_WARN|M_ERRNO, "openvpn_execve: GetExitCodeProcess %S failed", cmd); CloseHandle (proc_info.hProcess); } else { msg (M_WARN|M_ERRNO, "openvpn_execve: CreateProcess %S failed", cmd); } free (env); gc_free (&gc); } else if (!exec_warn && (script_security < SSEC_SCRIPTS)) { msg (M_WARN, SCRIPT_SECURITY_WARNING); exec_warn = true; } } else { msg (M_WARN, "openvpn_execve: called with empty argv"); } return ret;}
开发者ID:AVESH-RAI,项目名称:guizmovpn,代码行数:63,
示例6: MyCreateProcessWstatic BOOL WINAPIMyCreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation){ if (VERBOSITY >= 2) { debugPrintf("inject: intercepting %s(/"%S/", /"%S/", ...)/n", __FUNCTION__, lpApplicationName, lpCommandLine); } BOOL bRet; bRet = CreateProcessW(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags | CREATE_SUSPENDED, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation); MyCreateProcessCommon(bRet, dwCreationFlags, lpProcessInformation); return bRet;}
开发者ID:haraldF,项目名称:apitrace,代码行数:35,
示例7: MakeUpdaterCommandLinevoid AutoUpdateChecker::TriggerUpdate(const AutoUpdateChecker::NewVersionInformation& info){#ifdef _WIN32 std::map<std::string, std::string> updater_flags; updater_flags["this-manifest-url"] = info.this_manifest_url; updater_flags["next-manifest-url"] = info.next_manifest_url; updater_flags["content-store-url"] = info.content_store_url; updater_flags["parent-pid"] = std::to_string(GetCurrentProcessId()); updater_flags["install-base-path"] = File::GetExeDirectory(); updater_flags["log-file"] = File::GetExeDirectory() + DIR_SEP + UPDATER_LOG_FILE; // Copy the updater so it can update itself if needed. std::string updater_path = File::GetExeDirectory() + DIR_SEP + UPDATER_FILENAME; std::string reloc_updater_path = File::GetExeDirectory() + DIR_SEP + UPDATER_RELOC_FILENAME; File::Copy(updater_path, reloc_updater_path); // Run the updater! std::wstring command_line = MakeUpdaterCommandLine(updater_flags); STARTUPINFO sinfo = {sizeof(info)}; PROCESS_INFORMATION pinfo; INFO_LOG(COMMON, "Updater command line: %s", UTF16ToUTF8(command_line).c_str()); if (!CreateProcessW(UTF8ToUTF16(reloc_updater_path).c_str(), const_cast<wchar_t*>(command_line.c_str()), nullptr, nullptr, FALSE, 0, nullptr, nullptr, &sinfo, &pinfo)) { ERROR_LOG(COMMON, "Could not start updater process: error=%d", GetLastError()); }#endif}
开发者ID:delroth,项目名称:dolphin,代码行数:29,
示例8: MyCreateProcessWBOOL WINAPI MyCreateProcessW( LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpThreadAttributes, LPSECURITY_ATTRIBUTES lpProcessAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation ){ PROCESS_INFORMATION pi; if (!CreateProcessW( lpApplicationName, lpCommandLine, lpThreadAttributes, lpProcessAttributes, bInheritHandles, dwCreationFlags | CREATE_SUSPENDED, lpEnvironment, lpCurrentDirectory, lpStartupInfo, &pi )) return FALSE; DEBUGSTR( L"CreateProcessW: /"%s/", /"%s/"", (lpApplicationName == NULL) ? L"" : lpApplicationName, (lpCommandLine == NULL) ? L"" : lpCommandLine ); Inject( &pi, lpProcessInformation, dwCreationFlags ); return TRUE;}
开发者ID:aliking,项目名称:ansicon,代码行数:32,
示例9: ExecDWORD Exec(MSIHANDLE hModule, const WCHAR *pwszAppName, WCHAR *pwszCmdLine, const WCHAR *pwszWorkDir, DWORD *pdwExitCode){ STARTUPINFOW si; PROCESS_INFORMATION pi; DWORD rc = ERROR_SUCCESS; ZeroMemory(&si, sizeof(si)); si.dwFlags = STARTF_USESHOWWINDOW;#ifdef UNICODE si.dwFlags |= CREATE_UNICODE_ENVIRONMENT;#endif si.wShowWindow = SW_HIDE; /* For debugging: SW_SHOW; */ si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); logStringW(hModule, L"Executing command line: %s %s (Working Dir: %s)", pwszAppName, pwszCmdLine, pwszWorkDir == NULL ? L"Current" : pwszWorkDir); SetLastError(0); if (!CreateProcessW(pwszAppName, /* Module name. */ pwszCmdLine, /* Command line. */ NULL, /* Process handle not inheritable. */ NULL, /* Thread handle not inheritable. */ FALSE, /* Set handle inheritance to FALSE .*/ 0, /* No creation flags. */ NULL, /* Use parent's environment block. */ pwszWorkDir, /* Use parent's starting directory. */ &si, /* Pointer to STARTUPINFO structure. */ &pi)) /* Pointer to PROCESS_INFORMATION structure. */ { rc = GetLastError(); logStringW(hModule, L"Executing command line: CreateProcess() failed! Error: %ld", rc); return rc; } /* Wait until child process exits. */ if (WAIT_FAILED == WaitForSingleObject(pi.hProcess, 30 * 1000 /* Wait 30 secs max. */)) { rc = GetLastError(); logStringW(hModule, L"Executing command line: WaitForSingleObject() failed! Error: %u", rc); } else { if (!GetExitCodeProcess(pi.hProcess, pdwExitCode)) { rc = GetLastError(); logStringW(hModule, L"Executing command line: GetExitCodeProcess() failed! Error: %u", rc); } } /* Close process and thread handles. */ CloseHandle(pi.hProcess); CloseHandle(pi.hThread); logStringW(hModule, L"Executing command returned: %u (exit code %u)", rc, *pdwExitCode); return rc;}
开发者ID:bayasist,项目名称:vbox,代码行数:59,
示例10: system/*** Implementation of system() - requires wide char conversion*/RTEXP int system( const char *command ) { wchar_t wcmdline[BUFSIZ]; BOOL ret; PROCESS_INFORMATION pi; MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, command, -1, wcmdline, BUFSIZ); ret = CreateProcessW(wcmdline, NULL, NULL, NULL, (BOOL)NULL, CREATE_NEW_CONSOLE, NULL, NULL, NULL, &pi); return(0);}
开发者ID:luaforge,项目名称:lua4wince,代码行数:11,
示例11: forkvoid SessionProcess::exec(const Configuration& config, boost::function<void (bool)> onReady){#ifndef WT_WIN32 std::string parentPortOption = std::string("--parent-port=") + boost::lexical_cast<std::string>(acceptor_->local_endpoint().port()); const std::vector<std::string> &options = config.options(); const char **c_options = new const char*[options.size() + 2]; std::size_t i = 0; for (; i < options.size(); ++i) { c_options[i] = options[i].c_str(); } c_options[i] = parentPortOption.c_str(); ++i; c_options[i] = 0; pid_ = fork(); if (pid_ < 0) { LOG_ERROR("failed to fork dedicated session process, error code: " << errno); stop(); if (!onReady.empty()) { onReady(false); } return; } else if (pid_ == 0) {#ifdef WT_THREADED sigset_t mask; sigfillset(&mask); pthread_sigmask(SIG_UNBLOCK, &mask, 0);#endif // WT_THREADED execv(c_options[0], const_cast<char *const *>(c_options)); // An error occurred, this should not be reached exit(1); } delete[] c_options;#else // WT_WIN32 STARTUPINFOW startupInfo; ZeroMemory(&startupInfo, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); std::wstring commandLine = GetCommandLineW(); commandLine += L" --parent-port=" + boost::lexical_cast<std::wstring>(acceptor_->local_endpoint().port()); LPWSTR c_commandLine = new wchar_t[commandLine.size() + 1]; wcscpy(c_commandLine, commandLine.c_str()); if(!CreateProcessW(0, c_commandLine, 0, 0, true, 0, 0, 0, &startupInfo, &processInfo_)) { LOG_ERROR("failed to start dedicated session process, error code: " << GetLastError()); stop(); if (!onReady.empty()) { onReady(false); } } delete c_commandLine;#endif // WT_WIN32}
开发者ID:NovaWova,项目名称:wt,代码行数:58,
示例12: service_start_processstatic DWORD service_start_process(struct service_entry *service_entry, HANDLE *process){ PROCESS_INFORMATION pi; STARTUPINFOW si; LPWSTR path = NULL; DWORD size; BOOL r; service_lock_exclusive(service_entry); if (service_entry->config.dwServiceType == SERVICE_KERNEL_DRIVER) { static const WCHAR winedeviceW[] = {'//','w','i','n','e','d','e','v','i','c','e','.','e','x','e',' ',0}; DWORD len = GetSystemDirectoryW( NULL, 0 ) + sizeof(winedeviceW)/sizeof(WCHAR) + strlenW(service_entry->name); if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return ERROR_NOT_ENOUGH_SERVER_MEMORY; GetSystemDirectoryW( path, len ); lstrcatW( path, winedeviceW ); lstrcatW( path, service_entry->name ); } else { size = ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName,NULL,0); path = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR)); if (!path) return ERROR_NOT_ENOUGH_SERVER_MEMORY; ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName,path,size); } ZeroMemory(&si, sizeof(STARTUPINFOW)); si.cb = sizeof(STARTUPINFOW); if (!(service_entry->config.dwServiceType & SERVICE_INTERACTIVE_PROCESS)) { static WCHAR desktopW[] = {'_','_','w','i','n','e','s','e','r','v','i','c','e','_','w','i','n','s','t','a','t','i','o','n','//','D','e','f','a','u','l','t',0}; si.lpDesktop = desktopW; } service_entry->status.dwCurrentState = SERVICE_START_PENDING; service_unlock(service_entry); r = CreateProcessW(NULL, path, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); HeapFree(GetProcessHeap(),0,path); if (!r) { service_lock_exclusive(service_entry); service_entry->status.dwCurrentState = SERVICE_STOPPED; service_unlock(service_entry); return GetLastError(); } service_entry->status.dwProcessId = pi.dwProcessId; *process = pi.hProcess; CloseHandle( pi.hThread ); return ERROR_SUCCESS;}
开发者ID:bilboed,项目名称:wine,代码行数:58,
示例13: ZeroMemoryDWORD KCallInfocSend::_LaunchAppEx(LPCWSTR lpczApp, LPWSTR lpszCmdLine, BOOL bWait, PDWORD pdwExitCode/*=NULL*/, BOOL bShowWnd/*=TRUE*/){ DWORD dwResult = -1; STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); si.dwFlags = STARTF_USESHOWWINDOW; if (bShowWnd == FALSE) si.wShowWindow = SW_HIDE; else si.wShowWindow = SW_SHOW; // Start the child process. if ( !CreateProcessW( lpczApp, lpszCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi) ) { dwResult = GetLastError(); OutputDebugString(L"_LaunchAppEx:error"); goto Exit0; } if (bWait) { if (WaitForSingleObject(pi.hProcess, defMAXWAITPROCESSTIME) == WAIT_OBJECT_0) if (pdwExitCode) GetExitCodeProcess(pi.hProcess, pdwExitCode); } dwResult = 0;Exit0: if (pi.hProcess != NULL) { CloseHandle(pi.hProcess); pi.hProcess = NULL; } if (pi.hThread != NULL) { CloseHandle(pi.hThread); pi.hThread = NULL; } return dwResult;}
开发者ID:6520874,项目名称:pcmanager,代码行数:58,
示例14: GetCurrentDirectoryWbool CResourceCompilerHelper::InvokeResourceCompiler( const char *szSrcFile, const bool bWindow ) const{ bool bRet = true; // make command for execution wchar_t wMasterCDDir[512]; GetCurrentDirectoryW(512,wMasterCDDir); SettingsManagerHelpers::CFixedString<wchar_t, 512> wRemoteCmdLine; SettingsManagerHelpers::CFixedString<wchar_t, 512> wDir; wRemoteCmdLine.appendAscii("Bin32/rc/"); wRemoteCmdLine.appendAscii(RC_EXECUTABLE); wRemoteCmdLine.appendAscii(" /""); wRemoteCmdLine.append(wMasterCDDir); wRemoteCmdLine.appendAscii("//"); wRemoteCmdLine.appendAscii(szSrcFile); wRemoteCmdLine.appendAscii("/" /userdialog=0"); wDir.append(wMasterCDDir); wDir.appendAscii("//Bin32//rc"); STARTUPINFOW si; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); si.dwX = 100; si.dwY = 100; si.dwFlags = STARTF_USEPOSITION; PROCESS_INFORMATION pi; ZeroMemory( &pi, sizeof(pi) ); if (!CreateProcessW( NULL, // No module name (use command line). const_cast<wchar_t*>(wRemoteCmdLine.c_str()), // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. bWindow?0:CREATE_NO_WINDOW, // creation flags. NULL, // Use parent's environment block. wDir.c_str(), // Set starting directory. &si, // Pointer to STARTUPINFO structure. &pi)) // Pointer to PROCESS_INFORMATION structure. { bRet = false; } // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); return bRet;}
开发者ID:Aytunes,项目名称:Tanks,代码行数:57,
示例15: CommandLinePtr/** * Constructs a CProcess object and uses the CreateProcessW function to start the process immediately. * * @param CommandLine * A std::wstring containing the command line to run * * @param StartupInfo * Pointer to a STARTUPINFOW structure containing process startup information */CProcess::CProcess(const wstring& CommandLine, LPSTARTUPINFOW StartupInfo){ auto_array_ptr<WCHAR> CommandLinePtr(new WCHAR[CommandLine.size() + 1]); wcscpy(CommandLinePtr, CommandLine.c_str()); if(!CreateProcessW(NULL, CommandLinePtr, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, StartupInfo, &m_ProcessInfo)) TESTEXCEPTION("CreateProcessW failed/n");}
开发者ID:Moteesh,项目名称:reactos,代码行数:18,
示例16: _WCHstatic RVOID relaunchInPermanentLocation ( ){ RPWCHAR bootstrapLocations[] = { _WCH( "%SYSTEMDRIVE%//$Recycle.Bin//MALWARE_DEMO_WINDOWS_1.exe" ), _WCH( "%SYSTEMDRIVE%//RECYCLER//MALWARE_DEMO_WINDOWS_1.exe" ), _WCH( "%windir%//system32//tasks//MALWARE_DEMO_WINDOWS_1.exe" ), _WCH( "%USERPROFILE%//MALWARE_DEMO_WINDOWS_1.exe" ) }; RU32 i = 0; STARTUPINFOW startupInfo = {0}; PROCESS_INFORMATION procInfo = {0}; RPWCHAR expandedPath = NULL; for( i = 0; i < ARRAY_N_ELEM( bootstrapLocations ); i++ ) { rpal_debug_info( "trying to move to bootstrap location %d...", i ); rpal_file_delete( bootstrapLocations[ i ], FALSE ); if( rpal_file_move( g_self_path, bootstrapLocations[ i ] ) ) { rpal_debug_info( "successfully moved to bootstrap location!" ); rpal_debug_info( "launching in new location (%ls)...", bootstrapLocations[ i ] ); if( rpal_string_expand( bootstrapLocations[ i ], &expandedPath ) && 0 != CreateProcessW( expandedPath, NULL, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &procInfo ) ) { rpal_debug_info( "successfully launched from new location." ); } else { rpal_debug_error( "error launching from permanent location: %d.", GetLastError() ); } if( NULL != expandedPath ) { rpal_memory_free( expandedPath ); } break; } else { rpal_debug_warning( "could not move to new bootstrap location, may not have permission..." ); } }}
开发者ID:refractionPOINT,项目名称:limacharlie,代码行数:57,
示例17: sizeofvoid ProcessWin::ForkAndExec(){ nativeIn->CreateHandles(); nativeOut->CreateHandles(); nativeErr->CreateHandles(); STARTUPINFO startupInfo; startupInfo.cb = sizeof(STARTUPINFO); startupInfo.lpReserved = NULL; startupInfo.lpDesktop = NULL; startupInfo.lpTitle = NULL; startupInfo.dwFlags = STARTF_FORCEOFFFEEDBACK | STARTF_USESTDHANDLES; startupInfo.cbReserved2 = 0; startupInfo.lpReserved2 = NULL; //startupInfo.hStdInput = nativeIn->GetReadHandle(); //startupInfo.hStdOutput = nativeOut->GetWriteHandle(); //startupInfo.hStdError = nativeErr->GetWriteHandle(); HANDLE hProc = GetCurrentProcess(); nativeIn->DuplicateRead(hProc, &startupInfo.hStdInput); nativeOut->DuplicateWrite(hProc, &startupInfo.hStdOutput); nativeErr->DuplicateWrite(hProc, &startupInfo.hStdError); std::string commandLine(ArgListToString(args)); std::wstring commandLineW(::UTF8ToWide(commandLine)); logger->Debug("Launching: %s", commandLine.c_str()); PROCESS_INFORMATION processInfo; BOOL rc = CreateProcessW(NULL, (wchar_t*) commandLineW.c_str(), NULL, NULL, TRUE, CREATE_NO_WINDOW, // If this is a console application, NULL, // don't open a console window. NULL, &startupInfo, &processInfo); //CloseHandle(nativeIn->GetReadHandle()); CloseHandle(startupInfo.hStdInput); CloseHandle(startupInfo.hStdOutput); CloseHandle(startupInfo.hStdError); if (!rc) { std::string message = "Error launching: " + commandLine; logger->Error(message); throw ValueException::FromString(message); } else { CloseHandle(processInfo.hThread); this->pid = processInfo.dwProcessId; this->process = processInfo.hProcess; this->running = true; }}
开发者ID:Defachko,项目名称:titanium_desktop,代码行数:57,
示例18: run_processunsigned WINAPI run_process(void * pParam){ PROCESS_INFORMATION pi; STARTUPINFOW si; WCHAR wcmd[VALUE_LEN+1] = {0}; WCHAR wdirectory[VALUE_LEN+1] = {0}; DWORD dwCreat = 0; int flags = get_parameters(wdirectory, wcmd, VALUE_LEN); if (flags<0) { return (0); } /* 如果是预启动,直接返回 */ if ( parse_shcommand() ) { return (0); } if ( GetLastError() == ERROR_ALREADY_EXISTS ) { return (0); } if ( wcslen(wcmd)>0 && !search_process(wcmd,0) ) { fzero(&si,sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_MINIMIZE; if (!flags) { si.wShowWindow = SW_HIDE; dwCreat |= CREATE_NEW_PROCESS_GROUP; } if(!CreateProcessW(NULL, (LPWSTR)wcmd, NULL, NULL, FALSE, dwCreat, NULL, (LPCWSTR)wdirectory, &si,&pi)) {#ifdef _LOGDEBUG logmsg("CreateProcessW error %lu/n",GetLastError());#endif return (0); } g_handle[0] = pi.hProcess; CloseHandle(pi.hThread); if ( pi.dwProcessId >4 && (SleepEx(6000,FALSE) == 0) ) { search_process(NULL, pi.dwProcessId); } } return (1);}
开发者ID:Firef0x,项目名称:pcxfirefox,代码行数:56,
示例19: RunAndTraceDWORD WINAPI RunAndTrace(){ STARTUPINFO siStartupInfo; CONTEXT ctxMainThread; ZeroMemory(&siStartupInfo,sizeof(siStartupInfo)); ZeroMemory(&piProcInfo,sizeof(piProcInfo)); siStartupInfo.cb = sizeof(STARTUPINFO); ctxMainThread.ContextFlags = CONTEXT_FULL; if(CreateProcessW(tcNewFilePath, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED | DEBUG_ONLY_THIS_PROCESS, NULL, NULL, &siStartupInfo, &piProcInfo)) { if(!GetThreadContext(piProcInfo.hThread,&ctxMainThread)) { TerminateProcess(piProcInfo.hProcess,-1); MessageBoxA(hwDlgMainFrame,"ERROR: Couldn C++ CreateProgram函数代码示例 C++ CreateProcessA函数代码示例
|