BOOL MYXXX::OnInitDialog()
{
...
m_wndListCtrl.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
m_wndListCtrl.InsertColumn(0xffff, "cntThreads", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "cntUsage", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "dwFlags", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "dwSize", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "pcPriClassBase", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "szExeFile", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "th32DefaultHeapID", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "th32ModuleID", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "th32ParentProcessID", LVCFMT_LEFT, 80, 0);
m_wndListCtrl.InsertColumn(0xffff, "th32ProcessID", LVCFMT_LEFT, 80, 0);
SetTimer(1, 1000, NULL);
...
}
void myxxx::OnTimer(UINT nId)
{
HANDLE hSnapshot;
PROCESSENTRY32 processListStr;
processListStr.dwSize = sizeof PROCESSENTRY32;
BOOL bRet;
int i;
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
bRet = Process32First(hSnapshot, &processListStr);
m_wndList.ResetContent();
m_wndListCtrl.DeleteAllItems();
while (bRet)
{
CString str;
int nIndex;
str.Format("%d", processListStr.cntThreads);
nIndex = m_wndListCtrl.InsertItem(0xffff, str, 0);
str.Format("%d", processListStr.cntUsage);
m_wndListCtrl.SetItem(nIndex, 1, 1, str, 0, 0, 0, 0);
str.Format("%d", processListStr.dwFlags);
m_wndListCtrl.SetItem(nIndex, 2, 1, str, 0, 0, 0, 0);
str.Format("%d", processListStr.dwSize);
m_wndListCtrl.SetItem(nIndex, 3, 1, str, 0, 0, 0, 0);
str.Format("%d", processListStr.pcPriClassBase);
m_wndListCtrl.SetItem(nIndex, 4, 1, str, 0, 0, 0, 0);
str.Format("%s", processListStr.szExeFile);
m_wndListCtrl.SetItem(nIndex, 5, 1, str, 0, 0, 0, 0);
str.Format("%d", processListStr.th32DefaultHeapID);
m_wndListCtrl.SetItem(nIndex, 6, 1, str, 0, 0, 0, 0);
str.Format("%d", processListStr.th32ModuleID);
m_wndListCtrl.SetItem(nIndex, 7, 1, str, 0, 0, 0, 0);
str.Format("%d", processListStr.th32ParentProcessID);
m_wndListCtrl.SetItem(nIndex, 8, 1, str, 0, 0, 0, 0);
str.Format("%d", processListStr.th32ProcessID);
m_wndListCtrl.SetItem(nIndex, 9, 1, str, 0, 0, 0, 0);
bRet = Process32Next(hSnapshot, &processListStr);
}
CDialog::OnTimer(nIDEvent);
}
有问题联系我
本文地址:http://com.8s8s.com/it/it22198.htm