• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ WaitForInputIdle函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中WaitForInputIdle函数的典型用法代码示例。如果您正苦于以下问题:C++ WaitForInputIdle函数的具体用法?C++ WaitForInputIdle怎么用?C++ WaitForInputIdle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了WaitForInputIdle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: m_free

Process::ProcessImpl::ProcessImpl(const std::string& cmd, const std::vector<std::string>& argv) :
    m_free(false)
{
    std::string args;
    for (unsigned int i = 0; i < argv.size(); ++i) {
        args += argv[i];
        if (i + 1 < argv.size())
            args += ' ';
    }

    ZeroMemory(&m_startup_info, sizeof(STARTUPINFO));
    m_startup_info.cb = sizeof(STARTUPINFO);
    ZeroMemory(&m_process_info, sizeof(PROCESS_INFORMATION));

    if (!CreateProcess(const_cast<char*>(cmd.c_str()), const_cast<char*>(args.c_str()), 0, 0, false, 
        CREATE_NO_WINDOW, 0, 0, &m_startup_info, &m_process_info)) {
            std::string err_str;
            DWORD err = GetLastError();
            DWORD flags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM;
            LPSTR buf;
            if (FormatMessageA(flags, 0, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, 0)) {
                err_str += buf;
                LocalFree(buf);
            }
            throw std::runtime_error("Process::Process : Failed to create child process.  Windows error was: \"" + err_str + "\"");
        }
        WaitForInputIdle(m_process_info.hProcess, 1000); // wait for process to finish setting up, or for 1 sec, which ever comes first
}
开发者ID:fourmond,项目名称:freeorion,代码行数:28,代码来源:Process.cpp


示例2: WaitForInputIdle

STDMETHODIMP CShellExt::SendToWindow(HANDLE hProcess, LPCSTR pszText)
{
    //Wait for the process to be ready to accept input
    WaitForInputIdle(hProcess, INFINITE);
    CSendKeys sk;
    sk.SendKeys(pszText);
    return NOERROR;
}
开发者ID:vim-scripts,项目名称:gvimext.dll--support-tabs-under-VIM-7,代码行数:8,代码来源:gvimext.cpp


示例3: WaitForInputIdle

WaitResult System::WaitInputIdle( const HProcess & hProcess, UInt iMilliseconds ) const
{
    DWord dwResult = WaitForInputIdle( hProcess.m_hThreadingObject, (DWord)iMilliseconds );
    if ( dwResult == 0 )
        return WAIT_OK;
    if ( dwResult == WAIT_TIMEOUT )
        return WAIT_EXPIRED;
    return WAIT_ERROR;
}
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:9,代码来源:System.cpp


示例4: ErrorBox

//通过匿名管道连接引擎引擎
bool CEngine::LinkEngineWithUnnamed()
{
	status = 0;//引擎连接未就绪

	SECURITY_ATTRIBUTES sa;
	sa.nLength=sizeof(SECURITY_ATTRIBUTES);
	sa.lpSecurityDescriptor=NULL;//Default security attributes
	sa.bInheritHandle= TRUE;//handle can be inherited

	if(!CreatePipe(&pde.engine_read,&pde.platform_write,&sa,BUFSIZE) ||!CreatePipe(&pde.platform_read,&pde.engine_write,&sa,BUFSIZE))//创建两个平台与引擎之间互相通信的匿名管道
	{
		ErrorBox("CreatePipe failed");
		return false;
	}

	char Filter[]="(exe files)|*.exe|(all files)|*.*||";//文件滤镜	
	CFileDialog FileName(true,NULL,NULL,Filter,NULL,gameSet.EngineInitDir);//定义文件对话框类实例
	if(FileName.DoModal()==IDOK)
	{
		path=FileName.GetFilePath();
		LPCTSTR folder=FileName.GetFolderPath(path);
		char EngineDir[MAX_PATH]={0};
		strcpy(EngineDir,folder);
				
		STARTUPINFO si;
		PROCESS_INFORMATION pi;
		ZeroMemory(&si,sizeof(si));
		si.cb=sizeof(si);
		si.dwFlags=STARTF_USESHOWWINDOW |STARTF_USESTDHANDLES;
		si.wShowWindow=SW_HIDE;
		si.hStdInput=pde.engine_read;
		si.hStdOutput=pde.engine_write;
		si.hStdError=pde.engine_write;
		if(!CreateProcess(path,"",NULL,NULL,true,0,NULL,EngineDir,&si,&pi))//打开引擎进程
		{
			ErrorBox("CreateProcess failed");
			status = -1;
			return false;
		}
		CloseHandle(pde.engine_read);
		CloseHandle(pde.engine_write);
		WaitForInputIdle(pi.hProcess,INFINITE);
		pde.hEProcess = pi.hProcess;
		CloseHandle(pi.hThread);
		SetCurrentDirectory(gameSet.CurDir);//恢复当前主应用程序的进程
		CreateEngineInfoBoard();
	}
	else
	{
		status = -1;
		return false;
	}

	return true;
}
开发者ID:ifplusor,项目名称:SAUGamePlatform,代码行数:56,代码来源:CEngine.cpp


示例5: cleanCommandLine

bool CCommonAppUtils::LaunchApplication
    ( const CString& sCommandLine
    , UINT idErrMessageFormat
    , bool bWaitForStartup
    , bool bWaitForExit
    , HANDLE hWaitHandle)
{
    PROCESS_INFORMATION process;

    // make sure we get a writable copy of the command line

    size_t bufferLen = sCommandLine.GetLength()+1;
    std::unique_ptr<TCHAR[]> cleanCommandLine (new TCHAR[bufferLen]);
    memcpy (cleanCommandLine.get(),
            (LPCTSTR)sCommandLine,
            sizeof (TCHAR) * bufferLen);

    if (!CCreateProcessHelper::CreateProcess(NULL, cleanCommandLine.get(), sOrigCWD, &process))
    {
        if(idErrMessageFormat != 0)
        {
            CFormatMessageWrapper errorDetails;
            CString msg;
            msg.Format(idErrMessageFormat, (LPCTSTR)errorDetails);
            CString title;
            title.LoadString(IDS_APPNAME);
            MessageBox(NULL, msg, title, MB_OK | MB_ICONINFORMATION);
        }
        return false;
    }
    AllowSetForegroundWindow(process.dwProcessId);

    if (bWaitForStartup)
        WaitForInputIdle(process.hProcess, 10000);

    if (bWaitForExit)
    {
        DWORD count = 1;
        HANDLE handles[2];
        handles[0] = process.hProcess;
        if (hWaitHandle)
        {
            count = 2;
            handles[1] = hWaitHandle;
        }
        WaitForMultipleObjects(count, handles, FALSE, INFINITE);
        if (hWaitHandle)
            CloseHandle(hWaitHandle);
    }

    CloseHandle(process.hThread);
    CloseHandle(process.hProcess);

    return true;
}
开发者ID:ch3cooli,项目名称:TSVNUtils,代码行数:55,代码来源:CommonAppUtils.cpp


示例6: edit

int ActivePet::launch(std::wstring exePath, std::wstring originalDocPath){

	wchar_t commandLine[4096] = { '\0' };
	if (originalDocPath != L"") {

		// Build the command line.
	    std::wstring editableDocPath = edit(originalDocPath);
		wcscat(commandLine, L"\"");
		wcscat(commandLine, exePath.c_str());
		wcscat(commandLine, L"\" \"");
		wcscat(commandLine, editableDocPath.c_str());
		wcscat(commandLine, L"\"");
	}
    auto_close<void*, &::DestroyEnvironmentBlock> environment(NULL);
	if (!CreateEnvironmentBlock(&environment, m_session.get(), FALSE)) {
        printf("CreateEnvironmentBlock() failed: %d", GetLastError());
		return -30;
	}
    STARTUPINFO si = { sizeof(STARTUPINFO) };
    PROCESS_INFORMATION pi = {};
	if (!CreateProcessAsUser(m_session.get(),
							 exePath.c_str(),
							 commandLine,
							 NULL,
							 NULL,
							 FALSE,
							 CREATE_SUSPENDED | CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE,
							 environment.get(),
							 NULL, // lpCurrentDirectory,
							 &si,
							 &pi)) {
        printf("CreateProcessAsUser() failed: %d", GetLastError());
		return -30;
	}
	if (!AssignProcessToJobObject(m_job.get(), pi.hProcess)) {
        printf("AssignProcessToJobObject() failed: %d", GetLastError());
		return -30;
	}
	if (!ResumeThread(pi.hThread)) {
        printf("ResumeThread() failed: %d", GetLastError());
		return -30;
	}
    if (WaitForInputIdle(pi.hProcess, INFINITE) != ERROR_SUCCESS) {
        printf("WaitForInputIdle() failed: %d", GetLastError());
		return -30;
	}
    InjectAndCall(pi.hProcess, "ApplyHooks", 10000);
	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);

    return 0;
}
开发者ID:hypronet,项目名称:Polaris-Open-Source,代码行数:52,代码来源:ActivePet.cpp


示例7: ExecuteTarget

STATIC int ExecuteTarget(LPTSTR lpCmdLine)
{
	HWND hWnd = NULL;
	// DWORD dwExitCode = ERROR_SUCCESS;
	PROCESS_INFORMATION pi = { 0 };
	STARTUPINFO si = { sizeof(STARTUPINFO), 0 };
	
	/* Execute the process */
	if (CreateProcess(
		NULL,	/* No module name (use command line) */
		lpCmdLine,	/* 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 */
		NULL,	/* Use parent's starting directory */
		&si,	/* Pointer to STARTUPINFO structure */
		&pi	/* Pointer to PROCESS_INFORMATION structure */
	)) {
		DWORD dwProcessId = 0;
		
		/* Wait until target executable has finished its initialization */
		WaitForInputIdle(pi.hProcess, INFINITE);

		/* Find target executable window */
		hWnd = GetTopWindow(0);
		while(hWnd != NULL) {
			GetWindowThreadProcessId(hWnd, &dwProcessId);
			if (dwProcessId == pi.dwProcessId) {
				/* And move it to the top. */
				SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
				break;
			}
			hWnd = GetNextWindow(hWnd, GW_HWNDNEXT);
		}

		/* Wait until target executable exits. */
		// Nah
		//WaitForSingleObject(pi.hProcess, INFINITE);
		//GetExitCodeProcess(pi.hProcess, &dwExitCode);

		/* Close process and thread handles. */
		CloseHandle(pi.hProcess);
		CloseHandle(pi.hThread);
	} else {
		FatalError(ERROR_SUCCESS, _T("Failed to execute cmdline: %s"), lpCmdLine);
		xfree(lpCmdLine);
	}
	
	return ERROR_SUCCESS;
}
开发者ID:juntalis,项目名称:FO4EditUtils,代码行数:52,代码来源:TES5EditStub.c


示例8: launch_putty

HWND launch_putty(int action, char *path)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    DWORD wait;
    HWND pwin;
    struct process_record *pr;
    char buf[BUFSIZE];

    memset(&si, 0, sizeof(STARTUPINFO));
    si.cb = sizeof(STARTUPINFO);

    memset(&pi, 0, sizeof(PROCESS_INFORMATION));

    sprintf(buf, "%s -%s \"%s\"", config->putty_path,
	    action ? "edit" : "load", path);

    if (!CreateProcess(config->putty_path, buf, NULL, NULL,
		       FALSE, 0, NULL, NULL, &si, &pi))
	return NULL;

    wait = WaitForInputIdle(pi.hProcess, LAUNCH_TIMEOUT);

    if (wait != 0) {
	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);
	return NULL;
    };

    CloseHandle(pi.hThread);

    pwin = NULL;
    EnumThreadWindows(pi.dwThreadId, FindPuttyWindowCallback, (LPARAM) &pwin);

    if (!pwin) {
	CloseHandle(pi.hProcess);
	return NULL;
    };

    pr = (struct process_record *) malloc(sizeof(struct process_record));
    pr->pid = pi.dwProcessId;
    pr->tid = pi.dwThreadId;
    pr->hprocess = pi.hProcess;
    pr->window = pwin;
    pr->path = dupstr(path);

    item_insert((void *) &process_handles, &nprocesses, pi.hProcess);
    nprocesses -= 1;
    item_insert((void *) &process_records, &nprocesses, pr);

    return pwin;
};
开发者ID:nohuhu,项目名称:TuTTY,代码行数:52,代码来源:misc.c


示例9: ASSERT

void StartupRunner::_SpawnProcess(LPTSTR ptzCommandLine, DWORD dwFlags)
{
    ASSERT(!(dwFlags & ERK_WAITFOR_QUIT && dwFlags & ERK_WAITFOR_IDLE));
    
    //
    // The following cases need to be supported:
    //
    // 1. "C:\Program Files\App\App.exe" -params
    // 2. C:\Program Files\App\App.exe -params
    // 3. App.exe -params  (App.exe is in %path% or HKLM->REGSTR_PATH_APPPATHS)
    // and all the above cases without arguments.
    //
    // Note that 'App.exe' may contain spaces too
    //
    // CreateProcess handles 1 and 2, ShellExecuteEx handles 1 and 3.
    // So if the first token doesn't contain path characters (':' or '\')
    // ShellExecuteEx is used. That's really ugly but it *should* work.
    //
    TCHAR tzToken[MAX_LINE_LENGTH] = { 0 };
    LPCTSTR ptzArgs = NULL;
    
    GetToken(ptzCommandLine, tzToken, &ptzArgs, FALSE);
    
    HANDLE hProcess = NULL;
    
    if (strchr(tzToken, _T('\\')) || strchr(tzToken, _T(':')))
    {
        hProcess = _CreateProcess(ptzCommandLine);
    }
    else
    {
        hProcess = _ShellExecuteEx(tzToken, ptzArgs);
    }
    
    if (hProcess != NULL)
    {
        if (dwFlags & ERK_WAITFOR_QUIT)
        {
            WaitForSingleObject(hProcess, INFINITE);
        }
        else if (dwFlags & ERK_WAITFOR_IDLE)
        {
            WaitForInputIdle(hProcess, INFINITE);
        }
        
        CloseHandle(hProcess);
    }
    else
    {
        TRACE("StartupRunner failed to launch '%s'", ptzCommandLine);
    }
}
开发者ID:merlin1991,项目名称:litestep,代码行数:52,代码来源:StartupRunner.cpp


示例10: DoDelay

//---------------------------------------------------------------------------
//do inter-key delay
void TPushKeys::DoKeyDelay()
{
	if (Process==NULL)
	{
		//timed delay
		DoDelay(KeyDelayValue);
	}
	else //wait for input buffer to empty from process passed to onpus event
	{
		WaitForInputIdle(Process,ProcessWait);
	}

}
开发者ID:henryfung01,项目名称:GameCode4,代码行数:15,代码来源:windows.cpp


示例11: _IL_Process_WaitForInputIdle

/*
 * private static bool WaitForInputIdle(IntPtr processHandle,
 *										int processID, int milliseconds);
 */
ILBool _IL_Process_WaitForInputIdle(ILExecThread *_thread,
									ILNativeInt processHandle,
									ILInt32 processID,
									ILInt32 milliseconds)
{
#ifdef IL_WIN32_PLATFORM
	return WaitForInputIdle((HANDLE)processHandle, (DWORD)milliseconds);
#else
	/* "Idle" has no meaning on non-Win32 platforms so just pretend
	   that the process is fully initialized and ready to go */
	return 1;
#endif
}
开发者ID:bencz,项目名称:DotGnu,代码行数:17,代码来源:lib_task.c


示例12: OpenProcess

bool CWSWindow::GetWindowFromProcID()
{
	m_hWnd = NULL;
	HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, TRUE, m_dwProcID);
	if (hProc == NULL)
	{
		LOG_WS_ERROR(_T("OpenProcess failed"));
		return false;
	}
	WaitForInputIdle(hProc, INFINITE);
	EnumWindows(&EnumWindowsProc, reinterpret_cast<LPARAM>(this));

	return (m_hWnd != NULL);
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:14,代码来源:WSWindow.cpp


示例13: ExtractLinks

static int ExtractLinks()
{
  static WCHAR szNotepad[16];
  PROCESS_INFORMATION pi = {0};
  STARTUPINFO si = {sizeof(STARTUPINFO)};
  lstrcpy(szNotepad, L"Notepad.exe");
  GetStartupInfo(&si);
  if(!CreateProcess(0, szNotepad, 0, 0, 0, 0, 0, 0, &si, &pi))
    return 0;
  WaitForInputIdle(pi.hProcess, INFINITE);
  EnumThreadWindows(pi.dwThreadId, NotepadMainWndFindProc, 0);
  CloseHandle(pi.hThread);
  CloseHandle(pi.hProcess);
  return 0;
}
开发者ID:shah-,项目名称:c-projs,代码行数:15,代码来源:Html.c


示例14: StartExplorer

BOOL StartExplorer(DWORD timeout, NS_UNUSED BOOL kill)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    TCHAR shellpath[MAX_PATH];

    OutputDebugString(_T("nsRE::StartExplorer"));

    if (FindWindow(SHELLWND, NULL))
        NS_FAILED(NULL, _T("Explorer already running"));

    GetWindowsDirectory(shellpath, MAX_PATH - 1);
    shellpath[MAX_PATH - 1] = 0;
    _tcsncat(shellpath, SHELL, MAX_PATH - 1);
    shellpath[MAX_PATH - 1] = 0;

    FakeStartupIsDone();

    memset(&pi, 0, sizeof(PROCESS_INFORMATION));
    memset(&si, 0, sizeof(STARTUPINFO));

    si.cb = sizeof(STARTUPINFO);

    if(!CreateProcess(NULL,     /* No module name (use command line) */
        shellpath,              /* 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 */
        NULL,                   /* Use parent's starting directory */
        &si,                    /* Pointer to STARTUPINFO structure */
        &pi))                   /* Pointer to PROCESS_INFORMATION structure */
        NS_FAILED(NULL, _T("Cannot spawn explorer process"));

    switch (WaitForInputIdle(pi.hProcess, timeout))
    {
        case 0            : break; /* OK */
        case WAIT_TIMEOUT :
            if (timeout == IGNORE) break; /* OK as requested */
            NS_FAILED(pi.hProcess, _T("Timeout while waiting for explorer process"));
        case WAIT_FAILED  : NS_FAILED(pi.hProcess, _T("Error while waiting for explorer process"));
        default           : NS_FAILED(pi.hProcess, _T("This should not be reached"));
    }

    return TRUE;
}
开发者ID:bendetat,项目名称:GitClicky,代码行数:47,代码来源:nsNative.c


示例15: InitDbgConsole

void InitDbgConsole()
{
	WCHAR CommandLine[200];
	STARTUPINFO siStartInfo;  
  //定义一个用于产生子进程的PROCESS_INFORMATION结构体 (定义见CreateProcess,函数说明)  
    PROCESS_INFORMATION piProcInfo; 

	SECURITY_ATTRIBUTES  sec_att;     
    sec_att.bInheritHandle       = TRUE;     
    sec_att.lpSecurityDescriptor = NULL;     
    sec_att.nLength              = sizeof(SECURITY_ATTRIBUTES);  

	if   (!CreatePipe(&hRead, &hWrite,&sec_att, 0))  
          return;  

	HANDLE hCurrentProcess;
	DuplicateHandle(GetCurrentProcess(),GetCurrentProcess(),GetCurrentProcess(),&hCurrentProcess, 0, TRUE, DUPLICATE_SAME_ACCESS);
	wsprintfW(CommandLine,L"DbgDisplay.exe %d %d",hRead,hCurrentProcess);
	ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );  
	siStartInfo.cb = sizeof(STARTUPINFO);  
	siStartInfo.wShowWindow=TRUE;//此成员设为TRUE的话则显示新建进程的主窗口
	siStartInfo.dwFlags  |= STARTF_USESHOWWINDOW;  
	/*siStartInfo.dwFlags  |= STARTF_USESTDHANDLES;  
	siStartInfo.hStdOutput = 0;     //意思是:子进程的stdout输出到hStdOutWrite  
	siStartInfo.hStdError  =  0;        //意思是:子进程的stderr输出到hStdErrWrite  
	siStartInfo.hStdInput  = hRead;  */
  
	// 产生子进程,具体参数说明见CreateProcess函数  
	int bSuccess = CreateProcess(NULL,  
      CommandLine,    // 子进程的命令行  
      NULL,                   // process security attributes  
      NULL,                   // primary thread security attributes  
      TRUE,                   // handles are inherited  
      CREATE_NEW_CONSOLE,                          // creation flags  
      NULL,                  // use parent's environment  
      NULL,                  // use parent's current directory  
      &siStartInfo,      // STARTUPINFO pointer  
      &piProcInfo);     // receives PROCESS_INFORMATION  
	
   //如果失败,退出  
	if (!bSuccess )
		return;  
	WaitForInputIdle(piProcInfo.hProcess,100);


}
开发者ID:Menooker,项目名称:AgentGo,代码行数:46,代码来源:DbgPipe.cpp


示例16: SteamLaunch

bool SteamLaunch(void)
{
	std::string	steamRoot = GetSteamRoot();
	_MESSAGE("steam root = %s", steamRoot.c_str());

	if(steamRoot.empty())
		return false;

	std::string	steamEXEPath = steamRoot + "\\Steam.exe";

	STARTUPINFO			startupInfo = { 0 };
	PROCESS_INFORMATION	procInfo = { 0 };

	startupInfo.cb = sizeof(startupInfo);

	if(!CreateProcess(
		steamEXEPath.c_str(),
		NULL,	// no args
		NULL,	// default process security
		NULL,	// default thread security
		FALSE,	// don't inherit handles
		0,		// no options
		NULL,	// no new environment block
		steamRoot.c_str(),	// new cwd
		&startupInfo, &procInfo))
	{
		PrintLoaderError("Launching Steam failed (%08X).", GetLastError());
		return false;
	}

	// this doesn't do anything useful
	//	bool result = SteamCheckActive();

	// this is an ugly hack. wait for steam to start pumping messages
	WaitForInputIdle(procInfo.hProcess, INFINITE);

	// and then you know some more just because even then it isn't ready
	Sleep(1000 * 5);

	// clean up
	CloseHandle(procInfo.hProcess);
	CloseHandle(procInfo.hThread);

	return true;
}
开发者ID:kassent,项目名称:SkyrimSouls-SE,代码行数:45,代码来源:Steam.cpp


示例17: GetTypeOfApp

/*
    Función: GetTypeOfApp
    Descripción: Obtiene el tipo de programa en funcion de la espera en la carga
                 de su interface grafico.
    Parametros: 
        program_name            - Nombre y ruta del programa a checkear
        
    Retorno: 
        _GUI_APP__ 
        _CONS_APP__
        _UNK_APP__ 
*/
int 
GetTypeOfApp( LPTSTR program_name )
{
    STARTUPINFO           startup_info;
    PROCESS_INFORMATION   process_information;
    int                   return_function;
    
    memset( & startup_info, 0, sizeof( STARTUPINFO ) );
    
    return_function = _UNK_APP__;
    
    if 
    ( 
        CreateProcess
        (  
            NULL                                  ,
            program_name                          ,
            NULL                                  ,
            NULL                                  ,
            FALSE                                 ,
            CREATE_SUSPENDED | CREATE_NEW_CONSOLE ,      
            NULL                                  ,
            NULL                                  ,
            & startup_info                        ,
            & process_information
        ) 
        == 
        0 
    )
        ShowGetLastErrorString( "GetTypeOfApp:CreateProcess(program_name)" );
    else
    {
        if ( WaitForInputIdle( process_information.hProcess, 0 ) == WAIT_FAILED)
            return_function = _CONS_APP__;
        else
            return_function = _GUI_APP__;
    }
    
    if ( TerminateProcess( process_information.hProcess, 0) == 0 )
        ShowGetLastErrorString( "GetTypeOfApp:TerminateProcess(program)" );
    
    return return_function;
}
开发者ID:David-Reguera-Garcia-Dreg,项目名称:phook,代码行数:55,代码来源:injectordll.c


示例18: puts

bool CProcessLauncher::CreateMyProcess()
{
	if( m_lProcessCount > 0 )
	{
		puts("Process is running." );
		return false;
	}

	bool bOK = false;
	if( m_pi.hProcess == NULL )
	{
		if( ::RunProcess( &m_pi, (char *)GetAppName(), GetAppDirectory(), false, NORMAL_PRIORITY_CLASS ) )
		{
			printf( "Process[%s - %d] created.\n", GetAppName(), m_pi.hProcess );

			DWORD dwResult = WAIT_OBJECT_0;
			if( GetStartWait() )
				dwResult = WaitForSingleObject( GetEvent(), 1000 * 120 );	// 실행 후의 데이타 로딩을 최대 2분 기다린다.
			else
				WaitForInputIdle( m_pi.hProcess, 3000 );		

			bOK = ( dwResult == WAIT_OBJECT_0 );

			printf( "Process[%s - %d] wait result:%d\n", GetAppName(), m_pi.hProcess, dwResult );
		}
	}

	if( bOK )
	{
		InterlockedIncrement( &m_lProcessCount );
		BeginMonitor();
	}
	
	if( m_pPeer )
	{
		BEFORESEND( ar, PACKETTYPE_PROCESS_CREATED2 );
		ar << (BYTE)bOK;
		ar << (DWORD)( bOK ? 0 : GetLastError() );
		SEND( ar, m_pPeer, DPID_SERVERPLAYER );
	}

	return bOK;
}
开发者ID:iceberry,项目名称:flyffsf,代码行数:43,代码来源:ProcessLauncher.cpp


示例19: spwanAndHook

void spwanAndHook(char *dlltoinject,opt *options){
	STARTUPINFO         sInfo;
	PROCESS_INFORMATION pInfo;

	printf("[Info] Launching process: %s\n",options->cmdline);
	ZeroMemory(&sInfo, sizeof(sInfo));
	sInfo.cb = sizeof(sInfo);
	ZeroMemory(&pInfo, sizeof(pInfo));

	if (CreateProcess(options->cmdline, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &sInfo, &pInfo))
	{
		char cmd[512];
		printf("[info] New pid: %d\n",pInfo.dwProcessId);
		sprintf(cmd,"EXECUTING \"%s\" HOOKING PID %d",options->cmdline,pInfo.dwProcessId);
		logger(options->ini,"injector",cmd,strlen(cmd));
		if(WaitForInputIdle((void*)pInfo.hProcess,1000)==WAIT_FAILED) {
			printf("[info] Wait failed, console app? good luck :p\n");
			injecta(pInfo.dwProcessId,dlltoinject,options);
			Sleep(1000);
		}else{
			injecta(pInfo.dwProcessId,dlltoinject,options);
		}
		if(options->waitKeyPress){
			printf("Press [intro] to resume process..\n");
			getchar();
		}
		ResumeThread((void*)pInfo.hThread);
	    CloseHandle(pInfo.hThread);
	    CloseHandle(pInfo.hProcess);
	}else{
		DWORD dwLastError=GetLastError();
		char lpBuffer[256];
	    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,                 // It´s a system error
	                     NULL,                                      // No string to be formatted needed
	                     dwLastError,                               // Hey Windows: Please explain this error!
	                     MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),  // Do it in the standard language
	                     lpBuffer,              // Put the message here
	                     sizeof(lpBuffer),                     // Number of bytes to store the message
	                     NULL);
		printf("[Error] Code %d - %s",GetLastError(),lpBuffer);
	}
}
开发者ID:340211173,项目名称:mandingo,代码行数:42,代码来源:main.c


示例20: StartExplorerShell

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// StartExplorerShell
// Try to start Explorer in shell mode
//
bool StartExplorerShell(DWORD dwWaitTimeout)
{
    bool bStarted = false;
    TCHAR szOldShell[MAX_PATH] = { 0 };

    DWORD dwCopied = GetPrivateProfileString(_T("boot"), _T("shell"), NULL,
        szOldShell, COUNTOF(szOldShell), _T("system.ini"));

    // If this user account has limited access rights and
    // the shell is in HKLM, GetPrivateProfileString returns 0
    if (dwCopied > 0 && dwCopied < (COUNTOF(szOldShell)-1))
    {
        if (WritePrivateProfileString(
            _T("boot"), _T("shell"), _T("explorer.exe"), _T("system.ini")))
        {
            // We have successfully set Explorer as shell, now launch it...
            SHELLEXECUTEINFO sei = { 0 };
            sei.cbSize = sizeof(sei);
            sei.fMask = SEE_MASK_DOENVSUBST | SEE_MASK_NOCLOSEPROCESS;
            sei.lpVerb = _T("open");
            sei.lpFile = _T("%windir%\\explorer.exe");

            if (LSShellExecuteEx(&sei))
            {
                // If we don't wait here, there'll be a race condition:
                // We may reset the 'shell' setting before Explorer reads it.
                if (WaitForInputIdle(sei.hProcess, dwWaitTimeout) == 0)
                {
                    bStarted = true;
                }

                CloseHandle(sei.hProcess);
            }

            WritePrivateProfileString(
                _T("boot"), _T("shell"), szOldShell, _T("system.ini"));
        }
    }

    return bStarted;
}
开发者ID:DamianSuess,项目名称:LiteStep,代码行数:46,代码来源:WinMain.cpp



注:本文中的WaitForInputIdle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WaitForMessage函数代码示例发布时间:2022-05-30
下一篇:
C++ WaitCommEvent函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap