Posted on 2010-09-13 19:14
傅先生 阅读(177)
评论(0) 编辑 收藏 引用 所属分类:
内核相关编程
// CreateP.cpp : Defines the entry point for the console application.
//这个程序是建立进程的实例,打开了CMD命令行程序,并显示了进程号和主线程号
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#define SZFILENAME ".\\TraceMe.exe" //目标文件名
int main(int argc, char* argv[])
{
printf("dfdfd");
char chPath[301]= "ToTelephone.exe";
char path[200]= "\\wordpad.exe";
::GetCurrentDirectory(300,(LPTSTR)chPath);//得到当前目录
strcat(chPath,path);
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &pi, sizeof(pi) );
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
// Start the child process
ShellExecute(NULL,NULL,_T("\\wordpad.exe"),NULL,chPath,SW_SHOW);
if(CreateProcess(chPath, "", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
}
else
{
}
return 0;
}