Proc.cpp
资源名称:(vc).rar [点击查看]
上传用户:wpp2016
上传日期:2010-02-01
资源大小:1250k
文件大小:3k
源码类别:
Telnet服务器
开发平台:
Visual C++
- // Proc.cpp : implementation file
- //
- #include "stdafx.h"
- #include "anywhere.h"
- #include "Proc.h"
- #include "thread1.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CProc dialog
- CProc::CProc(CWnd* pParent /*=NULL*/)
- : CDialog(CProc::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CProc)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CProc::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CProc)
- DDX_Control(pDX, IDC_LISTPROC, m_btlist);
- DDX_Control(pDX, IDCANCEL, m_btquit);
- DDX_Control(pDX, IDOK, m_btkill);
- DDX_Control(pDX, IDC_PROCLIST, m_proclist);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CProc, CDialog)
- //{{AFX_MSG_MAP(CProc)
- ON_BN_CLICKED(IDC_LISTPROC, OnListproc)
- ON_MESSAGE(WM_SETACTIVE,OnSetActive)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CProc message handlers
- void CProc::OnListproc()
- {
- CString ask,caption;
- ask.LoadString(IDS_ACTION_ASK);
- caption.LoadString(IDS_CAPTION);
- if (IDYES==MessageBox(ask,caption,MB_YESNO))
- {
- CWaitCursor wc;
- DWORD ThreadId;
- CString order="LISTPROC";
- strcpy(linkrc.sbuf,order);
- linkrc.m_hWnd=GetSafeHwnd();//将listproc对话框句柄付给线程
- hSend=CreateThread(NULL,0,SendThread,&linkrc,0,&ThreadId);
- SetWindowText("请稍候,正在向远程机器发出列举进程命令");
- m_btquit.EnableWindow(FALSE);
- m_btlist.EnableWindow(FALSE);
- m_btkill.EnableWindow(FALSE);
- }
- }
- LRESULT CProc::OnSetActive(WPARAM wParam,LPARAM lParam)
- {
- m_btquit.EnableWindow(TRUE);
- m_btlist.EnableWindow(TRUE);
- m_btkill.EnableWindow(TRUE);
- if ((BOOL)wParam) {
- CString text=*(CString*)lParam;
- CString order;
- order=text.Left(8);
- text=text.Right(text.GetLength()-8);
- if (order=="KILLPROC") {
- CString sSucmsg,caption;
- sSucmsg.LoadString(IDS_KILLPROC_OK);
- sSucmsg+=parameter;
- caption.LoadString(IDS_CAPTION);
- MessageBox(sSucmsg,caption,MB_OK);
- return 1;
- }//杀掉进程
- else if (order=="LISTPROC") {
- m_proclist.ResetContent();
- ListProc(text);
- return 1;
- }
- }
- return 0;
- }
- void CProc::ListProc(CString text)
- {
- BOOL bFinished=FALSE;
- int pos;
- while (!bFinished) {
- if ((pos=text.Find("/"))!=-1)
- {
- //text1=text.Left(pos);//为名字+长度(目录无长度)
- m_proclist.AddString(text.Left(pos));//文件名字
- text=text.Right(text.GetLength()-pos-1);
- //m_remote.SetItemData(num,1);//为目录
- }
- else bFinished=true;
- }//end while
- SetWindowText("进程管理");
- }
- void CProc::OnOK()
- {
- int i=m_proclist.GetCurSel();
- if (i==-1) return;
- CString ask,caption;
- ask.LoadString(IDS_ACTION_ASK);
- caption.LoadString(IDS_CAPTION);
- if (IDYES==MessageBox(ask,caption,MB_YESNO))
- {
- //CWaitCursor wc;
- DWORD ThreadId;
- m_proclist.GetText(i,parameter);
- CString order="KILLPROC"+parameter;
- strcpy(linkrc.sbuf,order);
- linkrc.m_hWnd=GetSafeHwnd();//将listproc对话框句柄付给线程
- hSend=CreateThread(NULL,0,SendThread,&linkrc,0,&ThreadId);
- SetWindowText("请稍候,正在向远程机器发出杀掉进程命令");
- }
- //CDialog::OnOK();
- }