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

C++ GetStartupInfo函数代码示例

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

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



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

示例1: _winstart

int _winstart(void)
{
	char *szCmd; STARTUPINFO startinfo;

	__set_app_type(__GUI_APP);
	_controlfp(0x10000, 0x30000);

	szCmd = GetCommandLine();
	if (szCmd)
	{
		while (' ' == *szCmd) szCmd++;
		if ('\"' == *szCmd)
		{
			while (*++szCmd)
				if ('\"' == *szCmd) { szCmd++; break; }
		}
		else
		{
			while (*szCmd && ' ' != *szCmd) szCmd++;
		}
		while (' ' == *szCmd) szCmd++;
	}

	GetStartupInfo(&startinfo);
	exit(WinMain(GetModuleHandle(NULL), NULL, szCmd,
		(startinfo.dwFlags & STARTF_USESHOWWINDOW) ?
			startinfo.wShowWindow : SW_SHOWDEFAULT));
}
开发者ID:00shiv,项目名称:Nimrod,代码行数:28,代码来源:wincrt1.c


示例2: MakeNSISProc

DWORD WINAPI MakeNSISProc(LPVOID p) {
  STARTUPINFO si={sizeof(si),};
  SECURITY_ATTRIBUTES sa={sizeof(sa),};
  SECURITY_DESCRIPTOR sd={0,};
  PROCESS_INFORMATION pi={0,};
  HANDLE newstdout=0,read_stdout=0;
  OSVERSIONINFO osv={sizeof(osv)};
  GetVersionEx(&osv);
  if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
    InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorDacl(&sd,true,NULL,false);
    sa.lpSecurityDescriptor = &sd;
  }
  else sa.lpSecurityDescriptor = NULL;
  sa.bInheritHandle = true;
  if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
    ErrorMessage(g_sdata.hwnd,"There was an error creating the pipe.");
    PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
    return 1;
  }
  GetStartupInfo(&si);
  si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
  si.wShowWindow = SW_HIDE;
  si.hStdOutput = newstdout;
  si.hStdError = newstdout;
  if (!CreateProcess(NULL,g_sdata.script,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
    char buf[MAX_STRING];
    wsprintf(buf,"Could not execute:\r\n %s.",g_sdata.script);
    ErrorMessage(g_sdata.hwnd,buf);
    CloseHandle(newstdout);
    CloseHandle(read_stdout);
    PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
    return 1;
  }
  char szBuf[1024];
  DWORD dwRead = 1;
  DWORD dwExit = !STILL_ACTIVE;
  while (dwExit == STILL_ACTIVE || dwRead) {
    PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
    if (dwRead) {
      ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
      szBuf[dwRead] = 0;
      LogMessage(g_sdata.hwnd, szBuf);
    }
    else Sleep(TIMEOUT);
    GetExitCodeProcess(pi.hProcess, &dwExit);
    // Make sure we have no data before killing getting out of the loop
    if (dwExit != STILL_ACTIVE) {
      PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
    }
  }

  g_sdata.retcode = dwExit;
  CloseHandle(pi.hThread);
  CloseHandle(pi.hProcess);
  CloseHandle(newstdout);
  CloseHandle(read_stdout);
  PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
  return 0;
}
开发者ID:kichik,项目名称:nsis-1,代码行数:60,代码来源:makensisw.cpp


示例3: ServerStart

void ServerStart(HWND hWnd, HWND hCaller, UINT uMsg)
{
	wchar_t qemu[256];
	wchar_t path[256];

	wchar_t hdb[256], hdc[256], hdd[256];
	wchar_t net_name[256];
	wchar_t qemu_args[2048];

	STARTUPINFO si;
	HANDLE hStatusThread;
	memset(&si, 0, sizeof(STARTUPINFO));

	ConfigGetString(L"qemu", qemu);
	ConfigGetString(L"path", path);
	if(wcslen(qemu) == 0 || wcslen(path) == 0)
		return;

	UpdateDrives(NULL);
	UpdateInterfaces(NULL);

	ConfigGetString(L"hdb", hdb);
	ConfigGetString(L"hdc", hdc);
	ConfigGetString(L"hdd", hdd);
	ConfigGetString(L"net_name", net_name);

	if(wcslen(net_name) == 0)
	{
		MessageBox(NULL, GetString(IDS_ERROR_NONET), GetString(IDS_CAPTION), MB_ICONEXCLAMATION | MB_OK);
		return;
	}
	if(wcslen(hdb) == 0 && wcslen(hdc) == 0 && wcslen(hdd) == 0)
	{
		MessageBox(NULL, GetString(IDS_ERROR_NODRIVE), GetString(IDS_CAPTION), MB_ICONEXCLAMATION | MB_OK);
		return;
	}

	wsprintf(qemu_args, L"\"%s\" -L . -m %d -net nic,model=%s -net tap,ifname=\"%s\" -hda %s",
		qemu, QEMU_MEM, QEMU_NIC, net_name, QEMU_SERVERIMG);
	if(wcslen(hdb) > 0)
		wsprintf(qemu_args, L"%s -hdb %s", qemu_args, hdb);
	if(wcslen(hdc) > 0)
		wsprintf(qemu_args, L"%s -hdc %s", qemu_args, hdc);
	if(wcslen(hdd) > 0)
		wsprintf(qemu_args, L"%s -hdd %s", qemu_args, hdd);
	wcscat_s(qemu_args, 2048, QEMU_ARGS);

	GetStartupInfo(&si);
	si.dwFlags	   = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_HIDE;

	if(!CreateProcess(qemu, qemu_args, NULL, NULL, FALSE, 0, NULL, path, &si, &gServer))
	{
		MessageBox(NULL, GetString(IDS_ERROR_START), GetString(IDS_CAPTION), MB_ICONSTOP | MB_OK);
		return;
	}

	hStatusThread = CreateThread(NULL, 0, StatusThread, (LPVOID)hWnd, 0, NULL);
	CloseHandle(hStatusThread);
}
开发者ID:Nadrin,项目名称:fsproxy,代码行数:60,代码来源:actions.c


示例4: execit

int execit(char *prog, char *args)
{
	BOOL ok;
	STARTUPINFO startup_info;
	PROCESS_INFORMATION proc_info;

	GetStartupInfo(&startup_info);

	ok = CreateProcess(
		prog,
		args,
		0, /*process security attributes*/
		0, /*thread security attributes*/
		FALSE,
		0, /*dwCreationFlags*/
		0, /*environment*/
		0, /*lpCurrentDirectory*/
		&startup_info,
		&proc_info
	);
	if(ok) {
		DWORD dw;
		dw = WaitForSingleObject(proc_info.hProcess, INFINITE);
		ok = (dw != 0xFFFFFFFF);
		CloseHandle(proc_info.hThread);
		CloseHandle(proc_info.hProcess);
	}

	return ok? 0 : -1;
}
开发者ID:Audacity-Team,项目名称:Audacity,代码行数:30,代码来源:main.c


示例5: GetStartupMonitor

// If possible, open our windows on the monitor where user
// have clicked our icon (shortcut on the desktop or TaskBar)
HMONITOR GetStartupMonitor()
{
	STARTUPINFO si = {sizeof(si)};
	MONITORINFO mi = {sizeof(mi)};
	POINT ptCur = {}, ptOut = {-32000,-32000};
	HMONITOR hStartupMonitor = NULL, hMouseMonitor, hPrimaryMonitor;

	GetStartupInfo(&si);
	GetCursorPos(&ptCur);

	// Get primary monitor, it's expected to be started at 0x0, but we can't be sure
	hPrimaryMonitor = MonitorFromPoint(ptOut, MONITOR_DEFAULTTOPRIMARY);

	// Get the monitor where mouse cursor is located
	hMouseMonitor = MonitorFromPoint(ptCur, MONITOR_DEFAULTTONEAREST);

	// si.hStdOutput may have a handle of monitor with shortcut or used taskbar
	if (si.hStdOutput && GetMonitorInfo((HMONITOR)si.hStdOutput, &mi))
	{
		hStartupMonitor = (HMONITOR)si.hStdOutput;
	}

	// Now, due to MS Windows bugs or just an inconsistence,
	// hStartupMonitor has hPrimaryMonitor, if program was started
	// from shortcut, even if it is located on secondary monitor,
	// if it was started by keyboard.
	// So we can trust hStartupMonitor value only when it contains
	// non-primary monitor value (when user clicks shortcut with mouse)
	if (hStartupMonitor && ((hStartupMonitor != hPrimaryMonitor) || (hStartupMonitor == hMouseMonitor)))
		return hStartupMonitor;

	// Otherwise - return monitor where mouse cursor is located
	return hMouseMonitor ? hMouseMonitor : hPrimaryMonitor;
}
开发者ID:akrisiun,项目名称:ConEmu,代码行数:36,代码来源:Monitors.cpp


示例6: GetModuleFileName

//重启程序
void CUtil::ReStart(BOOL bNormal) 
{ 
	PROCESS_INFORMATION   info; 
	STARTUPINFO startup; 
	TCHAR szPath[128]; 
	TCHAR *szCmdLine; 

	GetModuleFileName(AfxGetApp()-> m_hInstance,szPath,sizeof(szPath)); 
	szCmdLine= GetCommandLine(); 
	GetStartupInfo(&startup); 

	BOOL bSucc=CreateProcess(szPath,szCmdLine,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL, NULL,&startup,&info); 

	if(bNormal && bSucc) 
	{ 
		CWnd *pWnd= AfxGetMainWnd(); 

		if(pWnd != NULL) 
		{ 
			pWnd->PostMessage(WM_CLOSE,0,0); 
		} 
		else 
			ExitProcess(-1); 
	} 
	else 
		ExitProcess(-1); 
} 
开发者ID:iloveghq,项目名称:GaborPC,代码行数:28,代码来源:Util.cpp


示例7: run

void run(char *name){
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
  GetStartupInfo(&si);
  CreateProcess(0, name, 0, 0, 0, 0, 0, 0, &si, &pi);
  WaitForSingleObject(pi.hProcess, INFINITE);
}
开发者ID:Artoria,项目名称:cpack,代码行数:7,代码来源:pack.c


示例8: main

int main(int argc, char *argv[]) {
  BOOL result;
  const char *msg1 = "Hello, World!\n(CreateFile/WriteFile/CloseHandle)\n++++++++++++++(1)\n\n";
  const char *msg2 = "Hello, World!\n(CreateFile/WriteFile/CloseHandle)\n(2)\n\n";
  const char *fileName = "../temp/test-w-twice.txt";

  HANDLE fh1, fh2;

  DWORD errorCode;
  DWORD nWritten;
  
  PROCESS_INFORMATION processInformation;
  STARTUPINFO startupInfo;

  GetStartupInfo(&startupInfo);
  result = CreateProcess("child-process.exe", /* LPCTSTR lpApplicationName, */
                            "", /* LPTSTR lpCommandLine, */
                            NULL, /* LPSECURITY_ATTRIBUTES lpProcessAttributes, */
                            NULL, /* LPSECURITY_ATTRIBUTES lpThreadAttributes, */
                            FALSE, /* bInheritHandles, */
                         0, /* CREATE_NEW_CONSOLE,  DWORD dwCreationFlags, */
                            NULL, /* LPVOID lpEnvironment, */
                            NULL, /* LPCTSTR lpCurrentDirectory,*/
                            &startupInfo, /* LPSTARTUPINFO lpStartupInfo, */
                            &processInformation); /* LPPROCESS_INFORMATION lpProcessInformation */
  printf("in parent process\n");
  Sleep(5000);
  printf("terminating child\n");
  TerminateProcess(processInformation.hProcess, 0);
  printf("child terminated");

  ExitProcess(0);
}
开发者ID:bk1,项目名称:sysprogramming-examples,代码行数:33,代码来源:create-process.c


示例9: init

/*
	Name: init()

	Description: initialize console application.

	Parameters:
				[in] name - a name of the console application
							with a full path.

	Return value:
					ON SUCCESS: TRUE
					ON   ERROR: FALSE

	Revision: 29.01.2007
*/
bool console::init(const char *name, const char *args)
{
	// init security descriptor
	InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
	SetSecurityDescriptorDacl(&sd, true, NULL, false);

	// init security attributes
	sa.lpSecurityDescriptor = &sd;
	sa.nLength = sizeof(SECURITY_ATTRIBUTES);
	sa.bInheritHandle = true; // endble handle inherit

	// create pipes and I/O redirect
	CreatePipe(&newstdin, &write_stdin, &sa, 0);
	CreatePipe(&read_stdout, &newstdout, &sa, 0);

	// init startupinfo
	GetStartupInfo(&si);
	si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_HIDE;
	si.hStdOutput = newstdout;
	si.hStdError  = newstdout;
	si.hStdInput  = newstdin;

	char args_copy[10240];
	lstrcpy(args_copy, args);

	printf("Execute: [%s] [%s]\n", name, args_copy);
	if(0 == CreateProcess(name, args_copy, NULL, NULL, true, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi))
	{
		return false;
	}

	return true;
}
开发者ID:begoon,项目名称:stuff,代码行数:49,代码来源:console.cpp


示例10: InstallMe

void InstallMe(char *szInstallName)
{
     	 char szAppPath[MAX_PATH];
	 char szSystemPath[MAX_PATH];
	 char KeyValue[1024];
	 BOOL result;
	 STARTUPINFO sInfo;
  	 PROCESS_INFORMATION pInfo;

	 GetStartupInfo(&sInfo);
	 sInfo.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
	 sInfo.wShowWindow =SW_HIDE;

	 ZeroMemory(KeyValue,1024);
	 GetModuleFileName(GetModuleHandle(NULL),szAppPath,MAX_PATH);
	 GetSystemDirectory(szSystemPath,MAX_PATH);

	 strcat(szSystemPath,"\\");
	 strcat(szSystemPath,szInstallName);
	 strcat(szSystemPath,".exe");
	 
         pToFileCopy=(pFileCopy)GetProcAddress(GetModuleHandle("kernel32.dll"),"CopyFileA");
	 result=pToFileCopy("test.c","C:\\test2.c",1);
	 //CopyFile(szAppPath,szSystemPath,1);
	 strcat(KeyValue,EnDeCrypt(text,eKey));
         strcat(KeyValue," "); 
	 strcat(KeyValue,szSystemPath);
	 strcat(KeyValue," /F");
	 
	 CreateProcess(NULL,KeyValue,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&sInfo,&pInfo);
	       
开发者ID:scovell,项目名称:misc,代码行数:30,代码来源:modShell.c


示例11: main

int main(void)
{
    STARTUPINFO stup;
    PROCESS_INFORMATION pinfo;
    LONGLONG ct, et, kt, ut, elapse;
    SYSTEMTIME sct, set;
    char *call;
    call = GetCommandLine(); // string com a linha de comando
    call = skip_arg(call); // salta o 1.o argumento
    GetStartupInfo(&stup); // necessário para a criação de um novo processo
    CreateProcess(NULL, call, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL,&stup, &pinfo); // cria novo processo com parâmetros de chamada
    WaitForSingleObject(pinfo.hProcess, INFINITE); // espera que termine
    GetProcessTimes(pinfo.hProcess, (FILETIME *)&ct, (FILETIME *)&et,(FILETIME *)&kt, (FILETIME *)&ut);
    CloseHandle(pinfo.hProcess); // fecha handle do processo terminado
    CloseHandle(pinfo.hThread); // fecha handle do thread terminado
    elapse = et - ct;
    FileTimeToSystemTime((FILETIME *)&ct, &sct);
    FileTimeToSystemTime((FILETIME *)&et, &set);
    printf("\n\nStart time: %02d:%02d:%02d.%03d\n", sct.wHour, sct.wMinute,sct.wSecond, sct.wMilliseconds);
    printf("End time: %02d:%02d:%02d.%03d\n\n", set.wHour, set.wMinute,set.wSecond, set.wMilliseconds);
    printf("ELAPSED: %.3f ms  (%.3f s)\n", (double)elapse/10000, (double)elapse/1E7);
    printf("  Kernel: %.3f ms  (%.3f s)\n", (double)kt/10000, (double)kt/1E7);
    printf("  User: %.3f ms  (%.3f s)\n", (double)ut/10000, (double)ut/1E7);
    return 0;
}
开发者ID:mptrv,项目名称:pequenos-em-c,代码行数:25,代码来源:main.cpp


示例12: main

int main(int argc, char const *argv[])
{
	struct matrices multi;
	srand(time(NULL));
	int r = 0;
	int factores[N][N] = {0};
	printf("Matrices que se utilizaran:\n");
	printf("Matriz 1:\n");
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j){
			r = rand()%8 +1;
			multi.matriz1[i][j] = r;
			printf("%d\t",multi.matriz1[i][j]);
		}
		printf("\n");
	}
	printf("Matriz 2:\n");
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j){
			r = rand()%8 +1;
			multi.matriz2[i][j] = r;
			printf("%d\t",multi.matriz2[i][j]);
		}
		printf("\n");
	}

	DWORD escritos;
	HANDLE hLectPipe, hEscrPipe;
	PROCESS_INFORMATION piHijo;
	STARTUPINFO siHijo;
	SECURITY_ATTRIBUTES pipeSeg = {sizeof(SECURITY_ATTRIBUTES),NULL,TRUE};
	GetStartupInfo(&siHijo);
	
	CreatePipe(&hLectPipe,&hEscrPipe,&pipeSeg,0);
	WriteFile(hEscrPipe,&multi,sizeof(multi),&escritos,NULL);
	
	siHijo.hStdInput = hLectPipe;
	siHijo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
	siHijo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	siHijo.dwFlags = STARTF_USESTDHANDLES;
	
	CreateProcess(NULL,"thijo.exe",NULL,NULL,TRUE,0,NULL,NULL,&siHijo,&piHijo);
	WaitForSingleObject(piHijo.hProcess,INFINITE);
	
	
	CloseHandle(hLectPipe);
	CloseHandle(hEscrPipe);
	CloseHandle(piHijo.hThread);
	CloseHandle(piHijo.hProcess);
	
	/*printf("Ya multiplicada\n");
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j){
			printf("%d\t",factores[i][j]);
		}
		printf("\n");
	}*/
	
	return 0;
}
开发者ID:andreandyp,项目名称:CodigosC,代码行数:60,代码来源:tpadre.c


示例13: create_proc

void create_proc(char *cmd, char *arg1)
{
    PROCESS_INFORMATION pinfo;
    STARTUPINFO sinfo;
    char real_cmdline[1024];
    /* Windows wants argv[0] on cmdline. */
    _snprintf_s(real_cmdline, sizeof(real_cmdline), sizeof(real_cmdline),
                "%s %s", cmd, arg1);
    GetStartupInfo(&sinfo);
    if (!CreateProcess(cmd,     /* application name */
                       real_cmdline, /* command line */
                       NULL,    /* new proc cannot be inherited */
                       NULL,    /* new thread cannot be inherited */
                       TRUE,    /* inherit handles from this proc */
                       0,       /* no creation flags */
                       NULL,    /* use environment of this proc */
                       NULL,    /* same directory of this proc */
                       &sinfo,  /* start up info */
                       &pinfo   /* out: process information */
                       )) {
        print("ERROR creating new process: %s %s\n", cmd, arg1);
        exit(1);
    }
    /* Wait for the child for at least 90 secs (to avoid flakiness when
     * running the test suite: i#1414).
     */
    WaitForSingleObject(pinfo.hProcess, 90 * 1000);
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:28,代码来源:large_options.c


示例14: StartCmdLine

HANDLE StartCmdLine( LPSTR cmdLine ) {
 STARTUPINFO si; GetStartupInfo( &si );
 PROCESS_INFORMATION pi;
 if ( !CreateProcess( 0, cmdLine, 0, 0, 0, 0, 0, 0, &si, &pi )) ExitProcess( GetLastError());
 CloseHandle( pi.hThread );
 return pi.hProcess;
}
开发者ID:denis-ryzhkov,项目名称:antiques,代码行数:7,代码来源:proczomb.cpp


示例15: slash

int WindowsShellCommands::execWithData(const std::string &dir, const std::string &source) {
	std::string fullDirPath = workarea + slash(dir);
	std::string fullSourcePath = fullDirPath + slash(source);
	system(("copy \"" + fullSourcePath + "\" \"" + fullSourcePath + ".bat\"").c_str());

	PROCESS_INFORMATION pi;
	STARTUPINFO si;
	GetStartupInfo(&si);
	LARGE_INTEGER startTime, finishTime, counterFrequency;
	QueryPerformanceFrequency(&counterFrequency);
	QueryPerformanceCounter(&startTime);
	CreateProcess((fullSourcePath + ".bat").c_str(), NULL, NULL, NULL, FALSE, 0, NULL, fullDirPath.c_str(), &si, &pi);
	WaitForSingleObject(pi.hProcess, execData.time ? execData.time : INFINITE);
	TerminateProcess(pi.hProcess, 0);  
	QueryPerformanceCounter(&finishTime);
	execData.time = (finishTime.QuadPart - startTime.QuadPart) / (counterFrequency.QuadPart / 1000);
	
	PROCESS_MEMORY_COUNTERS pmc;
	GetProcessMemoryInfo(pi.hProcess, &pmc, sizeof(pmc));
	execData.memory = pmc.QuotaPeakNonPagedPoolUsage + pmc.QuotaPeakPagedPoolUsage;
	
	system(("del \"" + fullSourcePath + ".bat\"").c_str());
	GetExitCodeProcess(pi.hProcess, (LPDWORD)&execData.exitCode);
	return execData.exitCode;
}
开发者ID:vfolunin,项目名称:UJS_JI,代码行数:25,代码来源:WindowsShellCommands.cpp


示例16: forkit

int forkit(char *prog, char *args)
{
	BOOL ok;
	STARTUPINFO startup_info;
	PROCESS_INFORMATION proc_info;

	GetStartupInfo(&startup_info);

	ok = CreateProcess(
		prog,
		args,
		0, /*process security attributes*/
		0, /*thread security attributes*/
		FALSE,
		DETACHED_PROCESS, /*dwCreationFlags*/
		0, /*environment*/
		0, /*lpCurrentDirectory*/
		&startup_info,
		&proc_info
	);
	if(ok) {
		CloseHandle(proc_info.hThread);
		CloseHandle(proc_info.hProcess);
	}

	return ok? 0 : -2;
}
开发者ID:Audacity-Team,项目名称:Audacity,代码行数:27,代码来源:main.c


示例17: ExecuteCmd

//执行命令行并等待执行完毕
void ExecuteCmd(CString csCmd,CString csCurrentDirectory)
{
	STARTUPINFO   si={sizeof(si)};
	ZeroMemory(&si,sizeof(STARTUPINFO));
	PROCESS_INFORMATION pi;
	ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
	si.cb=sizeof(STARTUPINFO);   
	GetStartupInfo(&si);
	si.wShowWindow=SW_HIDE;   
	si.dwFlags   = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES; 
	if   (!CreateProcessW(NULL,csCmd.GetBuffer(),NULL,
		NULL,TRUE,NULL,NULL,csCurrentDirectory,&si,&pi))   
	{     
		AfxMessageBox(L"Error On CreateProcess",MB_OK|MB_ICONERROR);
		return;  
	}    
	DWORD dwResult=WaitForSingleObject(pi.hProcess,1500);
	if (WAIT_TIMEOUT==dwResult)
	{	
		CloseHandle(pi.hProcess);
		CloseHandle(pi.hThread);
		AfxMessageBox(L"Wait TimeOut",MB_OK|MB_ICONERROR);
		return;
	}
}
开发者ID:Tevic,项目名称:ISOCmdX,代码行数:26,代码来源:VirtualDrive.cpp


示例18: Process_start

int Process_start( IProcess* self )
{
	char* command_line = CharStringList_toCharString( (const char**) self->arguments );
	STARTUPINFO si;
	int status;
	self->pi = CRuntime_calloc( 1, sizeof( PROCESS_INFORMATION ) );
	GetStartupInfo( &si );

	if ( self->useAltStd )
	{
		si.dwFlags = STARTF_USESTDHANDLES;
		if ( self->io.h_in )    si.hStdInput  = self->io.h_in;
		if ( self->io.h_out )   si.hStdOutput = self->io.h_out;
		if ( self->io.h_error ) si.hStdError  = self->io.h_error;
	}

	status = CreateProcess( NULL, command_line, NULL, NULL, FALSE, 0, NULL, NULL, &si, self->pi );

	if ( 0 == status )
	{
		CRuntime_free( self->pi );
		self->pi = NULL;
	}
	CRuntime_free( command_line );
	return status;
}
开发者ID:danielbradley,项目名称:Build,代码行数:26,代码来源:Process.c


示例19: RunDisconnectScript

void
RunDisconnectScript(connection_t *c, int run_as_service)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    TCHAR cmdline[256];
    DWORD exit_code;
    struct _stat st;
    int i;

    /* Cut off extention from config filename and add "_down.bat" */
    int len = _tcslen(c->config_file) - _tcslen(o.ext_string) - 1;
    _sntprintf_0(cmdline, _T("%s\\%.*s_down.bat"), c->config_dir, len, c->config_file);

    /* Return if no script exists */
    if (_tstat(cmdline, &st) == -1)
        return;

    if (!run_as_service)
        SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_DISCONN_SCRIPT));

    CLEAR(si);
    CLEAR(pi);

    /* fill in STARTUPINFO struct */
    GetStartupInfo(&si);
    si.cb = sizeof(si);
    si.dwFlags = 0;
    si.wShowWindow = SW_SHOWDEFAULT;
    si.hStdInput = NULL;
    si.hStdOutput = NULL;

    /* make an env array with confg specific env appended to the process's env */
    WCHAR *env = c->es ? merge_env_block(c->es) : NULL;
    DWORD flags = CREATE_UNICODE_ENVIRONMENT;

    if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE,
                       (o.show_script_window ? flags|CREATE_NEW_CONSOLE : flags|CREATE_NO_WINDOW),
                       NULL, c->config_dir, &si, &pi))
    {
        free(env);
        return;
    }

    for (i = 0; i <= (int) o.disconnectscript_timeout; i++)
    {
        if (!GetExitCodeProcess(pi.hProcess, &exit_code))
            goto out;

        if (exit_code != STILL_ACTIVE)
            goto out;

        Sleep(1000);
    }
out:
    free(env);
    CloseHandle(pi.hThread);
    CloseHandle(pi.hProcess);
}
开发者ID:EagleErwin,项目名称:openvpn-gui,代码行数:59,代码来源:scripts.c


示例20: WinMainCRTStartup

void __cdecl WinMainCRTStartup()
{
    STARTUPINFO si;
    unsigned char *cl;
    int res;

    // check and init fpu if required,
    // exit if required, but not available
    if (_FPinit && (_FPinit() == 0)) ExitProcess(-2);

    // call c initialisers
    if (_initterm(__xi_a, __xi_z, 1)) ExitProcess(-3);

    // call c++ initialisers
    _initterm(__xc_a, __xc_z, 0);

    cl = GetCommandLine();

    if (cl == NULL) cl = "";

    // parse command line
    {
        unsigned char delim = ' ';

        // skip any leading whitespaces (just in case)
        while (*cl && *cl <= delim) ++cl;

        // skip one parameter, which should be the application filename
        for ( ; *cl > delim; ++cl)
        {
            if (*cl == '"') delim ^= ' ';
        }

        // skip any whitespaces before first command line argument
        while (*cl && *cl <= delim) ++cl;
    }

    // get startup info on how to show
    si.dwFlags = 0;
    GetStartupInfo(&si);

    // -WCRT- tag
    __asm {
        test  eax, 0x0a0d0a0d
        sub   eax, 0x54524357
        sub   eax, 0x0a0d0a0d
    }

    // call WinMain
    res =
	WinMain(
	    (HINSTANCE)GetModuleHandle(NULL),
	    NULL,
	    (LPSTR)cl,
	    (si.dwFlags & STARTF_USESHOWWINDOW) ? si.wShowWindow : SW_SHOWDEFAULT
	    );

    exit(res);
}
开发者ID:leishen,项目名称:wcrt,代码行数:59,代码来源:crt0win.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ GetStatus函数代码示例发布时间:2022-05-30
下一篇:
C++ GetStartTime函数代码示例发布时间: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