c++ CreateProcess调用dos命令

// test.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include <windows.h> #include <iostream>
#include <fstream>
#include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[])
{
TCHAR szPath[MAX_PATH];
GetSystemDirectory(szPath, sizeof(szPath)); wstring str = szPath;
str.append(L"\\cmd.exe"); wstring cmdStr= L"systeminfo"; STARTUPINFO si;
ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si);
si.wShowWindow = SW_HIDE; PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi)); TCHAR temp[] = L"/c systeminfo"; BOOL bRet = CreateProcess(str.c_str(), temp, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);//
if (bRet)
{
WaitForSingleObject(pi.hProcess, );// 等待程序退出
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
} system( "PAUSE ");
}
上一篇:Jena文档《An Introduction to RDF and the Jena RDF API》的译文


下一篇:C#程序中将图片转换为二进制字符串,并将二进制字符串转换为图片