学习VC 我从windows sdk开始学,推荐一本不错的书:王艳平的《Windows 程序设计》
第一个sdk程序,写下博客,以示纪念吧 :)
功能:打开Windows自带的命令行程序 cmd.exe
#include
<
windows.h
>
#include
<
stdio.h
>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
int
main(
int
argc,
char
*
argv[])
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
char szCommandLine[] = "cmd";
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
STARTUPINFO si = ...{ sizeof(si) };
PROCESS_INFORMATION pi;
si.dwFlags=STARTF_USESHOWWINDOW;
si.wShowWindow=1;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
BOOL bRet=::CreateProcess(
NULL,
szCommandLine,
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
if(bRet)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
::CloseHandle(pi.hThread);
::CloseHandle(pi.hProcess);
printf("新进程的进程ID号:%d ",pi.dwProcessId);
printf("新进程的主线程的ID号:%d ",pi.dwThreadId);
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
return 0;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
比较懒,注释就不写了,^-^