Enumerate system process core code (code)

xiaoxiao2021-03-06  39

Contains header files:

#include "tlhelp32.h"

Example:

Void CTerminateProcessdlg :: ONGETPROCESS ()

{

M_Listbox.resetContent ();

CString m_output;

Handle HProcessSnap = NULL;

PROCESSENTRY32 PE32 = {0};

HProcessSnap = CreateToolHelp32Snapshot (TH32CS_SNAPPROCESS, 0);

IF (HProcessSnap == (Handle) -1)

{

:: MessageBox (null, "query process failed! :(", "Error Tips", MB_OK);

}

PE32.dwsize = sizeof (ProcesSsentry32);

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, "There is an unexpected error!", "Error Tips", MB_OK);

}

CloseHandle (HProcessSnap);

}

转载请注明原文地址:https://www.9cbs.com/read-75193.html

New Post(0)