如果想知道现在都有什么程序在运行,要怎么做?

cds27 2001-07-28 03:28:02
如果想知道现在都有什么程序在运行,要怎么做?
最好附上范例。
...全文
70 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
panda_w 2001-07-30
  • 打赏
  • 举报
回复
枚举一下系统的进程:MSDN
PROCESSENTRY32
Describes an entry from a list that enumerates the processes residing in the system address space when a snapshot was taken.

typedef struct tagPROCESSENTRY32 {
DWORD dwSize;
DWORD cntUsage;
DWORD th32ProcessID;
ULONG_PTR th32DefaultHeapID;
DWORD th32ModuleID;
DWORD cntThreads;
DWORD th32ParentProcessID;
LONG pcPriClassBase;
DWORD dwFlags;
TCHAR szExeFile[MAX_PATH];
} PROCESSENTRY32;
typedef PROCESSENTRY32 *PPROCESSENTRY32;
Members
dwSize
Specifies the length, in bytes, of the structure. Before calling the Process32First function, set this member to sizeof(PROCESSENTRY32). If you do not initialize dwSize, Process32First will fail.
cntUsage
Number of references to the process. A process exists as long as its usage count is nonzero. As soon as its usage count becomes zero, a process terminates.
th32ProcessID
Identifier of the process. The contents of this member can be used by Win32 API elements.
th32DefaultHeapID
Identifier of the default heap for the process. The contents of this member has meaning only to the tool help functions. It is not a handle, nor is it usable by Win32 API elements.
th32ModuleID
Module identifier of the process. The contents of this member has meaning only to the tool help functions. It is not a handle, nor is it usable by Win32 API elements.
cntThreads
Number of execution threads started by the process.
th32ParentProcessID
Identifier of the process that created the process being examined. The contents of this member can be used by Win32 API elements.
pcPriClassBase
Base priority of any threads created by this process.
dwFlags
Reserved; do not use.
szExeFile
Path and filename of the executable file for the process.
Requirements
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Tlhelp32.h.
cds27 2001-07-29
  • 打赏
  • 举报
回复
说明一下。
processinfo是什么东东?
seesi 2001-07-28
  • 打赏
  • 举报
回复
HANDLE snapshot=CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0) ;
if(snapshot == NULL)return ;

m_lisProcess.SetRedraw(FALSE);
SHFILEINFO shSmall;
int nIndex;
CString str;

PROCESSENTRY32 processinfo ;
processinfo.dwSize=sizeof(processinfo) ;

BOOL status=Process32First(snapshot,&processinfo) ;
while (status)
{
m_nProcess++;
ZeroMemory(&shSmall, sizeof(shSmall));
SHGetFileInfo(processinfo.szExeFile,0,&shSmall,sizeof(shSmall),SHGFI_ICON | SHGFI_SMALLICON);
nIndex=m_imgSmall.Add(shSmall.hIcon);
nIndex=m_lisProcess.InsertItem(m_nProcess,processinfo.szExeFile,nIndex);
str.Format("%08X",processinfo.th32ProcessID);
m_lisProcess.SetItemText(nIndex,1,str);
str.Format("%08X",processinfo.th32ParentProcessID);
m_lisProcess.SetItemText(nIndex,2,str);

status = Process32Next (snapshot, &processinfo) ;
}
m_lisProcess.SetImageList(&m_imgSmall, LVSIL_SMALL);
m_lisProcess.SetRedraw(TRUE);


上面把所有运行的进程添加到m_lisProcess的ListCtrl里

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧