6 * Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> reactos <dot> org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 ProcessList_Create(HWND hListCtrl
)
30 column
.mask
= LVCF_TEXT
|LVCF_FMT
|LVCF_WIDTH
;
31 column
.fmt
= LVCFMT_LEFT
;
33 column
.pszText
= L
"Process";
35 (void)ListView_InsertColumn(hListCtrl
, 0, &column
);
37 column
.pszText
= L
"ProcessID";
39 (void)ListView_InsertColumn(hListCtrl
, 1, &column
);
40 ProcessList_Update(hListCtrl
);
44 ProcessList_Update(HWND hListCtrl
)
47 DWORD ProcessIds
[1024], BytesReturned
;
50 WCHAR strText
[MAX_PATH
] = L
"<unknown>";
53 (void)ListView_DeleteAllItems(hListCtrl
);
54 memset(&item
, 0, sizeof(LV_ITEM
));
55 item
.mask
= LVIF_TEXT
|LVIF_PARAM
;
56 item
.pszText
= strText
;
61 item
.pszText
= L
"<Kernel>";
62 (void)ListView_InsertItem(hListCtrl
, &item
);
63 item
.pszText
= strText
;
64 wsprintf(strText
, L
"%#08x", 0);
65 ListView_SetItemText(hListCtrl
, 0, 1, strText
);
67 /* Insert "deleted" */
70 item
.pszText
= L
"<deleted>";
71 (void)ListView_InsertItem(hListCtrl
, &item
);
72 item
.pszText
= strText
;
73 wsprintf(strText
, L
"%#08x", 1);
74 ListView_SetItemText(hListCtrl
, 1, 1, strText
);
79 item
.pszText
= L
"<all>";
80 (void)ListView_InsertItem(hListCtrl
, &item
);
81 item
.pszText
= strText
;
82 wsprintf(strText
, L
"%#08x", 2);
83 ListView_SetItemText(hListCtrl
, 1, 1, strText
);
85 if (!EnumProcesses(ProcessIds
, sizeof(ProcessIds
), &BytesReturned
))
89 cProcesses
= BytesReturned
/ sizeof(DWORD
);
94 for (i
= 1; i
< cProcesses
; i
++)
96 wsprintf(strText
, L
"<unknown>");
97 item
.lParam
= ProcessIds
[i
];
98 item
.iItem
= ListView_GetItemCount(hListCtrl
);
101 /* FIXME: HACK: ROS crashes when using OpenProcess with PROCESS_VM_READ */
102 hProcess
= OpenProcess(PROCESS_QUERY_INFORMATION
| PROCESS_VM_READ
, FALSE
, ProcessIds
[i
]);
105 GetModuleBaseName(hProcess
, NULL
, (LPWSTR
)strText
, MAX_PATH
);
106 CloseHandle(hProcess
);
108 (void)ListView_InsertItem(hListCtrl
, &item
);
110 wsprintf(strText
, L
"%#08x", ProcessIds
[i
]);
111 ListView_SetItemText(hListCtrl
, item
.iItem
, 1, strText
);