//
// Process WM_COMMAND message for window/dialog: ProcessPageDlg
//
void ProcessPageDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
// TODO: Add your message processing code here...
HWND hwndListbox1;
switch(id)
{
case IDCANCEL://关闭进程
HANDLE h;
INT b;
DWORD a;
ProcessInfo p2;
//取得列表框的句柄
hwndListbox1 = GetDlgItem(hwnd,IDC_LIST1);
//取得列表框当前所选项
b = ListBox_GetCurSel(hwndListbox1);
//如果选中任一项
if(b>=0)
{
//取得列表框对应项附加的指针
p2 = (ProcessInfo)ListBox_GetItemData(hwndListbox1,b);
if(p2!=0)
{
h = OpenProcess(PROCESS_ALL_ACCESS,TRUE,p2->ProcessID);
if(h==0)
MessageBox(0,"打开进程失败","~00~",0);
else
{
free(p2);
GetExitCodeProcess(h,&a);
if(TerminateProcess(h,a)!=0)
{
MessageBox(0,"成功关闭进程","~00~",0);
My_RunFileScan(hwndListbox1);
}
else
MessageBox(0,"关闭进程失败","~00~",0);
}
}
else
MessageBox(0,"进程ID得不到","~00~",0);
}
else
MessageBox(0,"请选择一个进程","~00~",0);
break;
case IDOK://刷新进程
//取得列表框的句柄,并清空列表框的内容
hwndListbox1 = GetDlgItem(hwnd,IDC_LIST1);
//显示进程名
My_RunFileScan(hwndListbox1);
}
}
// Dialog proc for page 1
LRESULT CALLBACK ProcessPageDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
switch(uMsg)
{
chHANDLE_DLGMSG (hwnd, WM_INITDIALOG,
ProcessPageDlg_OnInitDialog);
chHANDLE_DLGMSG (hwnd, WM_COMMAND, ProcessPageDlg_OnCommand);
}
return FALSE;
}
//
// Process WM_COMMAND message for window/dialog: WindowPageDlg
//
void WindowPageDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
// TODO: Add your message processing code here...
switch(id)
{
case IDOK://更新按钮
HWND hCurrentWindow;
TCHAR szText[255];
//取得列表框的句柄
HWND hwndListbox2 = GetDlgItem(hwnd,IDC_LIST2);
//取得父窗口(即属性表)的句柄
HWND hwndPropertySheet = GetParent(hwnd);
//MessageBox(0,"ok","0",0);
//清列表框
ListBox_ResetContent(hwndListbox2);
//获取第一个窗口
hCurrentWindow = GetWindow(hwndPropertySheet,GW_HWNDFIRST);
chASSERT(hCurrentWindow);
//枚举所有的窗口
while(hCurrentWindow != 0)
{
if(GetWindowText(hCurrentWindow,szText,255) > 0)
ListBox_AddString(hwndListbox2,szText);
//取下一个窗口
hCurrentWindow = GetWindow
(hCurrentWindow,GW_HWNDNEXT);
szText[0]='\0';
}
//break;
}
}
//
// Process WM_INITDIALOG message for window/dialog: WindowPageDlg
//
BOOL WindowPageDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
// TODO: Add your message processing code here...
//为列表框添加水平滚动条
SendMessage(GetDlgItem(hwnd, IDC_LIST2), LB_SETHORIZONTALEXTENT, 1000, 0);
return TRUE;
}
// Dialog proc for page 2
LRESULT CALLBACK WindowPageDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,