HANDLE hpro;
hpro=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);这两句
编译时说:
error C2065: 'CreateToolhelp32Snapshot' : undeclared identifier
error C2065: 'TH32CS_SNAPPROCESS' : undeclared identifier
‘CreateToolhelp32Snapshot’不是api函数吗?为什么会这样?缺少头文件?请帮忙。
hpro=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);这两句
编译时说:
error C2065: 'CreateToolhelp32Snapshot' : undeclared identifier
error C2065: 'TH32CS_SNAPPROCESS' : undeclared identifier
‘CreateToolhelp32Snapshot’不是api函数吗?为什么会这样?缺少头文件?请帮忙。
#include "tlhelp32.h"
示例:void CTerminateProcessDlg::OnGetProcess()
{
m_ListBox.ResetContent();//设置ListBox为空。
CString m_output;
HANDLE hProcessSnap=NULL;
PROCESSENTRY32 pe32={0};
hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hProcessSnap==(HANDLE)-1)
{
::MessageBox(NULL,"查询进程失败!:(","错误提示",MB_OK);
}
pe32.dwSize=sizeof(PROCESSENTRY32);
if(Process32First(hProcessSnap,&pe32))
{
do
{
m_output.Format("%-20s ID:%-5d",pe32.szExeFile,pe32.th32ProcessID);
m_ListBox.AddString(m_output);
}
while(Process32Next(hProcessSnap,&pe32));
}
else
{
::MessageBox(NULL,"出现意外错误!","错误提示",MB_OK);
}
CloseHandle(hProcessSnap);}