显示当前进程

来源:互联网 发布:龙岩新罗天气预报软件 编辑:程序博客网 时间:2024/06/06 03:47

#include   <tlhelp32.h>  

void CProginfoDlg::OnButton1()
{

//其中m_lstProg为CListBox。
 // TODO: Add your control notification handler code here
  HANDLE   hsnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  PROCESSENTRY32   pe;
  CString   ProcessName;
  CString   ProcessID;
  CString   BasePriority;
  CString str;

  int retval=Process32First(hsnapshot,&pe);
  int   CurItemIndex=0;
  m_lstProg.ResetContent();
  do
  {
  ProcessName=pe.szExeFile;
  ProcessID.Format( "%d ",pe.th32ProcessID);
  BasePriority.Format( "%d ",pe.pcPriClassBase);
  str = ProcessName + ProcessID + BasePriority;
  str.Format(_T(str)); //这里 格式 一点 要注意
  m_lstProg.AddString(str);
  }
  while(Process32Next(hsnapshot,&pe));
  CloseHandle(hsnapshot);

}

原创粉丝点击