BOOL CreateProcess(
LPCTSTR 【lpApplicationName】, //指向可执行模块名称的指针
LPTSTR 【lpCommandLine】, //指向命令行字符串的指针
LPSECURITY_ATTRIBUTES 【lpProcessAttributes】, //指向进程安全属性的指针
LPSECURITY_ATTRIBUTES 【lpThreadAttributes】, //指向线程安全属性的指针
BOOL 【bInheritHandles】, //处理继承标志
DWORD 【dwCreationFlags】, //创建标志
LPVOID 【// pointer to new environment block】, //指向新的环境块
LPCTSTR 【lpCurrentDirectory】, //指向当前目录名称的指针
LPSTARTUPINFO 【lpStartupInfo】, //指向STARTUPINFO的指针
LPPROCESS_INFORMATION 【lpProcessInformation】 //指向PROCESS_INFORMATION的指针
);
// Process0617.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
void Getsi()
{
STARTUPINFO si;
GetStartupInfo(&si);
printf("%x %x %x %x %x %x %x %x ",si.dwX,si.dwY,si.dwXCountChars,si.dwYCountChars,si.dwFillAttribute,si.dwXSize,si.dwYSize,si.dwFlags);
}
BOOL CreateProcessFun(PTCHAR szAppName,PTCHAR szCmdLine)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si,sizeof(si));
ZeroMemory(&pi,sizeof(pi));
//si->cb = sizeof(si);
si.cb = sizeof(si);
if (!CreateProcess(szAppName,szCmdLine,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
{
printf("创建进程失败\n");
return FALSE;
}
else
{
printf("创建进程成功,进程句柄:%d--进程ID:%d--线程句柄:%d--线程ID:%d\n",pi.hProcess,pi.dwProcessId,pi.hThread,pi.dwThreadId);
return TRUE;
}
return TRUE;
}
int main(int argc, char* argv[])
{
TCHAR stcAppName[] = TEXT("C://Program Files//Internet Explorer//iexplore.exe");
TCHAR stcCmdLine[] = TEXT(" https://www.qq.com/");
CreateProcessFun(stcAppName,stcCmdLine);
getchar();
return 0;
}