⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threadlist.cpp

📁 关于进程&线程查看器 用过vc++自带的Process Viewer
💻 CPP
字号:
/*
 +------------------------------------------------------------+
 |															  |
 | (c) Copyright 2002, bigwhite, Inc.						  |
 |															  |
 | ALL RIGHTS RESERVED										  |
 |															  |
 +------------------------------------------------------------+
*/

 
/*==================================================================*
 * threadList.cpp : implementation file                             |
 *  Version 1.1                                                     |
 *=================================================================*/
//
// 
//

#include "stdafx.h"
#include "processdir.h"
#include "threadList.h"
#include "processdirDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CThreadList

IMPLEMENT_DYNCREATE(CThreadList, CListView)

CThreadList::CThreadList()
{
}

CThreadList::~CThreadList()
{
}


BEGIN_MESSAGE_MAP(CThreadList, CListView)
	//{{AFX_MSG_MAP(CThreadList)
	ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
////////////

/////////////////////////////////////////////////////////////////////////////
// CThreadList drawing

void CThreadList::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CThreadList diagnostics

#ifdef _DEBUG
void CThreadList::AssertValid() const
{
	CListView::AssertValid();
}

void CThreadList::Dump(CDumpContext& dc) const
{
	CListView::Dump(dc);
}
CProcessdirDoc* CThreadList::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CProcessdirDoc)));
	return (CProcessdirDoc*)m_pDocument;
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CThreadList message handlers

void CThreadList::OnInitialUpdate() 
{
	
	CListView::OnInitialUpdate();
    m_ilLarge.Create(IDB_LARGEDOC,16,1,RGB(255,0,255));
    GetListCtrl().SetImageList(&m_ilLarge,LVSIL_SMALL);
    
    GetListCtrl ().InsertColumn (0, "threadID", LVCFMT_CENTER, 92);
    GetListCtrl ().InsertColumn(1,"owner ID",LVCFMT_CENTER,128);
	GetListCtrl ().InsertColumn (2, "Base priority", LVCFMT_CENTER, 128);
    
    //GetListCtrl ().InsertColumn(3,"cnusage",LVCFMT_CENTER,92);   

}

BOOL CThreadList::PreCreateWindow(CREATESTRUCT& cs) 
{
	// TODO: Add your specialized code here and/or call the base class
	cs.style&=~LVS_TYPEMASK;
   cs.style|=LVS_REPORT;
	return CListView::PreCreateWindow(cs);


}

void CThreadList::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{   int numofthreads=0;
  	if(lHint==0x5A)
	{ 
		GetListCtrl().DeleteAllItems();
	
	CProcessInfo processinfo(TH32CS_SNAPALL);
	THREADENTRY32 te={sizeof(te)};
	BOOL fOk= processinfo.ThreadFirst(&te);
	for(;fOk;fOk=processinfo.ThreadNext(&te))
	{ //CString cntusage;
	  CString threadID;
	  CString ownerID;
	  CString Priority;
      threadID.Format("%8.8X",te.th32ThreadID);
      ownerID.Format("%8.8X",te.th32OwnerProcessID);
	  Priority.Format("%d",te.tpDeltaPri+te.tpBasePri);
	  //cntusage.Format("%d",te.cntUsage);
	  if(ownerID==(LPCTSTR)pHint) 
	  {
		GetListCtrl ().InsertItem(numofthreads,threadID);
        GetListCtrl ().SetItemText(numofthreads,1,ownerID);
		GetListCtrl ().SetItemText(numofthreads,2,Priority);
        //GetListCtrl ().SetItemText(numofthreads,3,cntusage);
		numofthreads++;
	  }
	}
	}
	if(lHint==0x6A)
	{GetListCtrl().DeleteAllItems();}
	CListView::OnUpdate(pSender,lHint,pHint);

}

void CThreadList::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -