|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <windows.h>
#include "resource.h"
#include <commctrl.h>
#pragma comment(lib,"comctl32.lib")
BOOL CALLBACK DialogProc(HWND, UINT, WPARAM, LPARAM);
INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
{
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&icex);
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
return 0;
}
VOID EnumProess(HWND hListProcess)
{
LV_ITEM vitem;
memset(&vitem, 0, sizeof(LV_ITEM));
vitem.mask = LVIF_TEXT;
//第一列
vitem.pszText = TEXT("csrss.exe");
vitem.cchTextMax = MAX_PATH;
vitem.iItem = 0;
vitem.iSubItem = 0;
//ListView_InsertItem(hListProcess, &vitem);
SendMessage(hListProcess, LVM_INSERTITEM, 0, (LPARAM)&vitem);
//第二列
vitem.pszText = TEXT("448");
vitem.iItem = 0;
vitem.iSubItem = 1;
ListView_InsertItem(hListProcess, &vitem);
//第三列
vitem.pszText = TEXT("1");
vitem.iItem = 0;
vitem.iSubItem = 2;
ListView_InsertItem(hListProcess, &vitem);
//第四列
vitem.pszText = TEXT("2");
vitem.iItem = 0;
vitem.iSubItem = 3;
ListView_InsertItem(hListProcess, &vitem);
}
VOID InitProcessListView(HWND hDlg) {
LV_COLUMN lv;
HWND hListProcess;
//初始化
memset(&lv, 0, sizeof(LV_COLUMN));
hListProcess = GetDlgItem(hDlg, IDC_LIST1);
SendMessage(hListProcess, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
//第一列
lv.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
lv.pszText =TEXT("进程");
lv.cx = 100;
lv.iSubItem = 0;
ListView_InsertColumn(hListProcess, 0, &lv);
//SendMessage(hListProcess, LVM_INSERTCOLUMN, 0, (DWORD)&lv);
//第二列
lv.pszText =TEXT("PDI");
lv.cx = 50;
lv.iSubItem = 1;
ListView_InsertColumn(hListProcess, 1, &lv);
//SendMessage(hListProcess, LVM_INSERTCOLUMN, 1, (DWORD)&lv);
//第三列
lv.pszText = TEXT("镜像基址");
lv.cx = 50;
lv.iSubItem = 2;
ListView_InsertColumn(hListProcess, 2, &lv);
//第四列
lv.pszText = TEXT("镜像大小");
lv.cx = 50;
lv.iSubItem = 3;
ListView_InsertColumn(hListProcess, 3, &lv);
EnumProess(hListProcess);
}
INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
InitProcessListView(hwnd);
TCHAR szBuffer[120];
SendDlgItemMessage(hwnd, IDC_LIST1, WM_SETTEXT, 0, (DWORD)szBuffer);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_BUTTON1:
break;
default:
break;
}
case WM_CLOSE:
EndDialog(hwnd,NULL);
break;
default:
return FALSE;
break;
}
return 0;
}
|
|