69,369
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
PROCESSENTRY32 pe32;
pe32.dwSize=sizeof(PROCESSENTRY32);
HANDLE showPro=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL);
if (showPro==INVALID_HANDLE_VALUE)
{
cout<<"f 1"<<endl;
return 0;
}
if (!Process32First(showPro,&pe32))
{
cout<<"f 2"<<endl;
return 0;
}
do
{
printf( "\nPROCESS NAME: %s \n", pe32.szExeFile );//这里只输出一个字符!!
cout<<"It's pid is "<<pe32.th32ProcessID<<endl;
} while (Process32Next(showPro,&pe32));
return 0;
}
// FunTest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
PROCESSENTRY32 pe32;
pe32.dwSize=sizeof(PROCESSENTRY32);
HANDLE showPro=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL);
if (showPro==INVALID_HANDLE_VALUE)
{
cout<<"f 1"<<endl;
return 0;
}
if (!Process32First(showPro,&pe32))
{
cout<<"f 2"<<endl;
return 0;
}
do
{
wcout << "\nPROCESS NAME: " << pe32.szExeFile << endl;
// wprintf( "\nPROCESS NAME: %s \n", (_TCHAR*)(&pe32.szExeFile) );//这里只输出一个字符!!
cout<<"It's pid is "<<pe32.th32ProcessID<<endl;
} while (Process32Next(showPro,&pe32));
system("pause");
return 0;
}