ShExecInfo.nShow = SW_HIDE
SHELLEXECUTEINFO ShExecInfo = {0}
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO)
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS
ShExecInfo.hwnd = NULL
ShExecInfo.lpVerb = NULL
ShExecInfo.lpFile = JudgeFilePath
ShExecInfo.lpParameters = commands
ShExecInfo.lpDirectory = NULL
ShExecInfo.nShow = SW_SHOWNORMAL
ShExecInfo.nShow = SW_HIDE
ShExecInfo.hInstApp = NULL
ShellExecuteEx(&ShExecInfo)
WaitForSingleObject(ShExecInfo.hProcess,INFINITE)
//vs2010通铅高过#include "stdafx.h"
#include <Windows.h>
#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )
/*此处设置链接选项,大致意思是程序基于windows子系统(不会创建控制汪棚台了),程序入口点mainCRTStarup(它会调用main函数)*/
int main(int argc, char* argv[])
{
WinExec("notepad",SW_SHOW)//这里是执行shell命令启动一个程序,当然你也可以带自己的参数,或槐陵尺者用creatprocess也是可以的,但是system("call notepad")不行,因为它的执行基于console子系统,所以又会导致出现控制台窗口
return 0
}
VC 获取进程线程枝枯颂数#include <tlhelp32.h>
void EnumProcess(void)
{
HANDLE hProcessSnap
HANDLE hProcess
PROCESSENTRY32 pe32
DWORD dwPriorityClass
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
return
}
pe32.dwSize = sizeof(PROCESSENTRY32)
if (!Process32First(hProcessSnap, &pe32))
{
CloseHandle(hProcessSnap)
return
}
do
{
//printf("%s", pe32.szExeFile)//完整文件名
//printf("%d", (int)pe32.cntThreads)//线程数
}while(Process32Next(hProcessSnap, &pe32))
CloseHandle(hProcessSnap)
}
如果要获取进程句柄
HANDLE hProcessHandle
hProcessHandle = OpenProcess(0x1F0FFF, true, ProcessID)//ProcessID进程ID
这个在控制台,Win32 SDK ,MFC 都败闷可以用的,只不过
SDK ,MFC 输出就 不用 printf 了,只猛郑要把获取的内容赋给变量就行了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)