ServicePage.cpp
上传用户:shouhua
上传日期:2014-12-06
资源大小:5685k
文件大小:17k
源码类别:

杀毒

开发平台:

Visual C++

  1. // ServicePage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "AntiEvilTools.h"
  5. #include "ServicePage.h"
  6. #include "ModulVer.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. char **pattern;
  13. int pattern_count;
  14. int nohideservice;
  15. int ischange;
  16. CModuleVersion *GoTo;
  17. MyList   *Gogogo;
  18. DWORD    CreateServer_StartType = SERVICE_AUTO_START;
  19. //CHiddenReg ChkReg;
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CServicePage property page
  22. IMPLEMENT_DYNCREATE(CServicePage, CPropertyPage)
  23. CServicePage::CServicePage() : CPropertyPage(CServicePage::IDD)
  24. {
  25. //{{AFX_DATA_INIT(CServicePage)
  26. // NOTE: the ClassWizard will add member initialization here
  27. //}}AFX_DATA_INIT
  28. }
  29. CServicePage::~CServicePage()
  30. {
  31. }
  32. void CServicePage::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CPropertyPage::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CServicePage)
  36. DDX_Control(pDX, IDC_LIST_SERVICE, m_list);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CServicePage, CPropertyPage)
  40. //{{AFX_MSG_MAP(CServicePage)
  41. ON_NOTIFY(NM_RCLICK, IDC_LIST_SERVICE, OnRclickProcessList)
  42. ON_COMMAND(ID_MENU_REF, OnMenuRef)
  43. ON_COMMAND(ID_SERVICE_START, OnServiceStart)
  44. ON_COMMAND(ID_GooleService, OnGooleService)
  45. ON_COMMAND(ID_SERVICE_DELETE, OnServiceDelete)
  46. ON_COMMAND(ID_SERVICE_STOP, OnServiceStop)
  47. ON_COMMAND(ID_SERVICE_AUTO, OnServiceAuto)
  48. ON_COMMAND(ID_SERVICE_MANAGER, OnServiceManager)
  49. ON_COMMAND(ID_SERVICE_DISABLE, OnServiceDisable)
  50. ON_COMMAND(ID_ServiceProperties, OnServiceProperties)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CServicePage message handlers
  55. BOOL CServicePage::OnInitDialog()
  56. {
  57. CDialog::OnInitDialog();
  58. CWinApp *pApp = AfxGetApp();
  59. CHeaderCtrl* pHeader = NULL;
  60. pHeader=m_list.GetHeaderCtrl();
  61. if(pHeader==NULL)
  62. return -1;
  63. //VERIFY(m_list.m_HeaderCtrl.SubclassWindow(pHeader->m_hWnd));
  64. m_pImage = new CImageList();
  65. ASSERT(m_pImage != NULL);    // serious allocation failure checking
  66. m_list.SetImageList(m_pImage, LVSIL_SMALL);
  67. m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
  68. Gogogo->InitSystemImageLists(m_list.m_hWnd);
  69. m_list.InsertColumn(0,"服务名称",LVCFMT_LEFT,100,-1);
  70. m_list.InsertColumn(1,"详细名称",LVCFMT_LEFT,200,-1);
  71. m_list.InsertColumn(2,"服务状态",LVCFMT_LEFT,60,-1);
  72. m_list.InsertColumn(3,"启动类型",LVCFMT_LEFT,60,-1);
  73. m_list.InsertColumn(4,"程序路径",LVCFMT_LEFT,240,-1);
  74. m_list.InsertColumn(5,"详细描述",LVCFMT_LEFT,300,-1);
  75.     OnView();
  76. return TRUE;
  77. }
  78. void CServicePage::OnView()
  79. {
  80. m_list.DeleteAllItems();
  81. UpdateData(false);
  82. LPQUERY_SERVICE_CONFIG ServicesInfo = NULL;
  83. LPENUM_SERVICE_STATUS lpServices    = NULL; 
  84. DWORD    nSize = 0; 
  85. DWORD    n; 
  86. DWORD    nResumeHandle = 0; 
  87. DWORD  dwServiceType = SERVICE_WIN32; 
  88. SC_HANDLE schSCManager = NULL; 
  89. BOOL     Flag = FALSE; 
  90. char szTemp[MAX_PATH];
  91. DWORD dwType=REG_SZ;
  92. char szFilePath[MAX_PATH];
  93. DWORD dwBufLen=MAX_PATH;
  94. if((schSCManager=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS))==NULL)
  95. {
  96. return;
  97. }
  98. lpServices = (LPENUM_SERVICE_STATUS) LocalAlloc(LPTR, 64 * 1024);        // Allocate Ram 
  99. EnumServicesStatus(schSCManager,
  100.    dwServiceType, 
  101.    SERVICE_STATE_ALL,
  102.    (LPENUM_SERVICE_STATUS)lpServices, 
  103.    64 * 1024, 
  104.    &nSize, 
  105.    &n, 
  106.    &nResumeHandle);
  107. int nitem = 0;
  108. for (unsigned long i = 0; i < n; i++) 
  109. SC_HANDLE service = NULL;
  110. DWORD     nResumeHandle = 0; 
  111. service=OpenService(schSCManager,lpServices[i].lpServiceName, SERVICE_ALL_ACCESS);
  112. ServicesInfo = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, 64 * 1024);        // Allocate Ram 
  113. QueryServiceConfig(service, ServicesInfo, 64 * 1024, &nResumeHandle);
  114. nitem=m_list.InsertItem(i, lpServices[i].lpServiceName);
  115. m_list.SetItemText(i, 1, lpServices[i].lpDisplayName);
  116. if ( lpServices[i].ServiceStatus.dwCurrentState == SERVICE_RUNNING)//SERVICE_STOPPED)
  117. {
  118. m_list.SetItemText(i, 2, "已启动");
  119. }
  120. else
  121. {
  122. m_list.SetItemText(i,2,"已停止");
  123. }
  124. CString stemp;
  125. LPQUERY_SERVICE_CONFIG lpServerConfig;
  126. LPSERVICE_DESCRIPTION  lpServerDesc;
  127. lpServerConfig=(LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, 4096);
  128. if(QueryServiceConfig(service,lpServerConfig,4096,&nResumeHandle))
  129. {
  130. switch(lpServerConfig->dwStartType)
  131. {
  132. case SERVICE_AUTO_START:
  133. stemp="自动";
  134. break;
  135. case SERVICE_BOOT_START:
  136. stemp="Boot";
  137. break;
  138. case SERVICE_DEMAND_START:
  139. stemp="手动";
  140. break;
  141. case SERVICE_DISABLED:
  142. stemp="禁用";
  143. break;
  144. case SERVICE_SYSTEM_START:
  145. stemp="系统";
  146. break;
  147. }
  148. m_list.SetItemText(i,3,stemp);
  149. stemp.Format("%s",lpServerConfig->lpBinaryPathName);
  150. memset(szTemp, 0, MAX_PATH);
  151. GoTo->ParseString(stemp, szTemp);
  152. CString strTemp;
  153. strTemp.Format("%s", szTemp);
  154. strTemp.MakeLower();
  155. if(strTemp.Find("svchost"))
  156. {
  157. HKEY hKEY;                                            
  158. CString subKey="SYSTEM\CurrentControlSet\Services\";
  159. subKey += lpServices[i].lpServiceName;
  160. subKey += "\Parameters\";
  161. long lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, subKey, 0, KEY_READ, &hKEY);
  162. if( lRet != ERROR_SUCCESS )
  163.  goto GoTo1;
  164. lRet = ::RegQueryValueEx(hKEY, "ServiceDll", NULL, &dwType, (LPBYTE)szFilePath, &dwBufLen);
  165. if( (lRet != ERROR_SUCCESS) || (dwBufLen > MAX_PATH) )
  166. {
  167. ::RegCloseKey(hKEY);
  168.  goto GoTo1;
  169. }
  170. memset(szTemp, 0, MAX_PATH);
  171. GoTo->ParseString(szFilePath, szTemp);
  172. GoTo1:
  173. strTemp.Format("%s", szTemp);
  174. memset(szTemp, 0, MAX_PATH);
  175. ::ExpandEnvironmentStrings(strTemp, szTemp, MAX_PATH);
  176. m_list.SetItemText(i,4,szTemp);
  177. }
  178. //MessageBox(szTemp);
  179. m_list.SetItem(i, 0, LVIF_TEXT | LVIF_IMAGE,lpServices[i].lpServiceName , 
  180. Gogogo->GetFileIcon(szTemp), 0, 0, 0);
  181. }
  182. LocalFree(lpServerConfig);
  183. lpServerDesc=(LPSERVICE_DESCRIPTION ) LocalAlloc( LPTR, 4096); 
  184. if (QueryServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, (LPBYTE)lpServerDesc,
  185. 4096, &nResumeHandle) ) 
  186. {
  187. stemp.Format("%s",lpServerDesc->lpDescription);
  188. m_list.SetItemText(i,5,stemp);
  189. }
  190. LocalFree(lpServerDesc);
  191. UpdateData(false);
  192. }
  193. }
  194. void CServicePage::OnRclickProcessList(NMHDR* pNMHDR, LRESULT* pResult) 
  195. {
  196. iSelected = m_list.GetNextItem(-1, LVNI_SELECTED);
  197. POINT point;
  198. ::GetCursorPos(&point);
  199. CMenu menu;
  200. menu.LoadMenu(IDR_MENU_SERVICE);
  201. menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
  202. *pResult = 0;
  203. }
  204. void CServicePage::OnMenuRef() 
  205. {
  206. // TODO: Add your command handler code here
  207. OnView();
  208. }
  209. void CServicePage::OnServiceStart() 
  210. {
  211. // TODO: Add your command handler code here
  212. EnablePriv();
  213. char ServerName[100]=" ";
  214. int x=m_list.GetSelectionMark();
  215. m_list.GetItemText(x,0,ServerName,100);
  216. SC_HANDLE scm;
  217.     SC_HANDLE service;
  218.     SERVICE_STATUS status;
  219. if((scm=OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE))==NULL)
  220. {
  221. //GoTo->PrintLog("打开服务管理器错误n");
  222. return;
  223. }
  224.     service=OpenService(scm,ServerName,SERVICE_ALL_ACCESS);
  225. if(!service)
  226. {
  227.        //GoTo->PrintLog("打开服务错误!n");
  228.    CloseServiceHandle(scm);
  229.    return;
  230. }
  231.     BOOL isSuccess=QueryServiceStatus(service,&status);
  232.     if (!isSuccess)
  233. {
  234.         //GoTo->PrintLog("查询服务错误!n");
  235. CloseServiceHandle(service );
  236. CloseServiceHandle(scm);
  237. return;
  238. }
  239.     if ( status.dwCurrentState==SERVICE_STOPPED )
  240. {
  241. isSuccess=::StartService(service,NULL,NULL);
  242. if (!isSuccess)
  243. {
  244.  MessageBox("启动服务失败!", "错误", MB_OK|MB_ICONERROR);
  245. }
  246. else
  247.  m_list.SetItemText(x, 2, "已启动");
  248.  MessageBox("启动服务成功!", "提示", MB_OK|MB_ICONINFORMATION);
  249. }
  250. }
  251. else
  252. {
  253. MessageBox("服务已经启动!", "提示", MB_OK|MB_ICONINFORMATION);
  254. }
  255. CloseServiceHandle(service );
  256. CloseServiceHandle(scm);
  257. }
  258. BOOL CServicePage::EnablePriv()
  259. {
  260.     HANDLE hToken;
  261. if ( OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,&hToken) )
  262. {
  263. TOKEN_PRIVILEGES tkp;
  264. LookupPrivilegeValue( NULL,SE_DEBUG_NAME,&tkp.Privileges[0].Luid );//修改进程权限
  265. tkp.PrivilegeCount=1;
  266. tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
  267. AdjustTokenPrivileges( hToken,FALSE,&tkp,sizeof tkp,NULL,NULL );//通知系统修改进程权限
  268. }
  269. return( (GetLastError()==ERROR_SUCCESS) );
  270. }
  271. void CServicePage::OnGooleService() 
  272. {
  273. // TODO: Add your command handler code here
  274. char GoogleName[100]=" ";
  275. int name=m_list.GetSelectionMark();
  276. m_list.GetItemText(name,0,GoogleName,100);
  277. CString FullName = "http://www.google.cn/search?q="+CString(GoogleName)+"服务";
  278.     ShellExecute(m_hWnd, NULL, FullName, NULL, NULL, SW_HIDE);
  279. }
  280. void CServicePage::OnServiceDelete() 
  281. {
  282. // TODO: Add your command handler code here
  283. EnablePriv();
  284. char ServerName[100]=" ";
  285. int x=m_list.GetSelectionMark();
  286. m_list.GetItemText(x,0,ServerName,100);
  287. SC_HANDLE scm;
  288.     SC_HANDLE service;
  289.     SERVICE_STATUS status;
  290. if((scm=OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE))==NULL)
  291. {
  292. return;
  293. }
  294.     service=OpenService(scm,ServerName,SERVICE_ALL_ACCESS|DELETE);
  295. if(!service)
  296. {
  297.    CloseServiceHandle(scm);
  298.    return;
  299. }
  300.     BOOL isSuccess=QueryServiceStatus(service,&status);
  301.     if (!isSuccess)
  302. {
  303. CloseServiceHandle(service );
  304. CloseServiceHandle(scm);
  305. return;
  306. }
  307.     if ( status.dwCurrentState!=SERVICE_STOPPED )
  308. {
  309.         isSuccess=ControlService(service,SERVICE_CONTROL_STOP,&status);
  310.         if (!isSuccess )
  311. {
  312. CloseServiceHandle(service );
  313. CloseServiceHandle(scm);
  314. return;
  315. }
  316. }
  317. isSuccess=::DeleteService(service);
  318. if (!isSuccess)
  319. {
  320.  MessageBox("删除服务失败!", "错误", MB_OK|MB_ICONERROR);
  321. }
  322. else
  323. HKEY hKey;
  324. CString regpath = "SYSTEM\CurrentControlSet\Services\";
  325.         regpath+= ServerName;
  326. if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, regpath, 0, KEY_ALL_ACCESS, &hKey) )
  327. {
  328. if(ERROR_SUCCESS !=  RegDeleteKey(hKey, regpath) )
  329. {
  330. RegCloseKey(hKey);     //随便删除下注册表里残留的东东
  331. // return;
  332. }
  333. }
  334. else
  335. {
  336. return ;
  337. }
  338. m_list.DeleteItem(x);
  339. MessageBox("删除服务成功!", "提示", MB_OK|MB_ICONINFORMATION);
  340. }
  341. CloseServiceHandle(service );
  342. CloseServiceHandle(scm);
  343. }
  344. void CServicePage::OnServiceStop() 
  345. {
  346. // TODO: Add your command handler code here
  347. EnablePriv();
  348. char ServerName[100]=" ";
  349. int x=m_list.GetSelectionMark();
  350. m_list.GetItemText(x,0,ServerName,100);
  351. SC_HANDLE scm;
  352.     SC_HANDLE service;
  353.     SERVICE_STATUS status;
  354. if((scm=OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE))==NULL)
  355. {
  356. return;
  357. }
  358.     service=OpenService(scm,ServerName,SERVICE_ALL_ACCESS);
  359. if(!service)
  360. {
  361.    CloseServiceHandle(scm);
  362.    return;
  363. }
  364.     BOOL isSuccess=QueryServiceStatus(service,&status);
  365.     if (!isSuccess)
  366. {
  367. CloseServiceHandle(service);
  368. CloseServiceHandle(scm);
  369. return;
  370. }
  371.     if ( status.dwCurrentState!=SERVICE_STOPPED )
  372. {
  373.         isSuccess=ControlService(service,SERVICE_CONTROL_STOP,&status);
  374.         if (!isSuccess )
  375. {
  376.             MessageBox("停止服务失败!", "错误", MB_OK|MB_ICONERROR);
  377. }
  378. else
  379. {
  380. m_list.SetItemText(x, 2, "已停止");
  381. MessageBox("停止服务成功!", "提示", MB_OK|MB_ICONINFORMATION);
  382. }
  383. }
  384. CloseServiceHandle(service);
  385. CloseServiceHandle(scm);
  386. }
  387. void CServicePage::OnServiceAuto() 
  388. {
  389. // TODO: Add your command handler code here
  390. EnablePriv();
  391. char ServerName[100]=" ";
  392. int x=m_list.GetSelectionMark();
  393. m_list.GetItemText(x,0,ServerName,100);
  394. SC_HANDLE scm;
  395.     SC_HANDLE service;
  396. if((scm=OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS))==NULL)
  397. {
  398. return;
  399. }
  400.     service=OpenService(scm,ServerName,SERVICE_ALL_ACCESS);
  401. if(!service)
  402. {
  403.    CloseServiceHandle(scm);
  404.    return;
  405. }
  406.     SC_LOCK sclLock; 
  407.     DWORD  dwStartType; 
  408.     sclLock = LockServiceDatabase(scm); 
  409.     if (sclLock == NULL) 
  410.     { 
  411. DWORD dwErr = GetLastError();
  412.         if (dwErr == ERROR_SERVICE_DATABASE_LOCKED) 
  413. {
  414. CloseServiceHandle(scm);
  415. return;
  416. }
  417. if(dwErr == ERROR_INVALID_HANDLE)
  418. {
  419. CloseServiceHandle(scm);
  420. return;
  421. }
  422. if(dwErr == ERROR_ACCESS_DENIED)
  423. {
  424. CloseServiceHandle(scm);
  425. return;
  426. }
  427. else
  428. {
  429. return;
  430. }        
  431.     }  
  432.     dwStartType = SERVICE_AUTO_START;
  433.     if (! ChangeServiceConfig( 
  434.         service,        // handle of service 
  435.         SERVICE_NO_CHANGE, // service type: no change 
  436.         dwStartType,       // change service start type 
  437.         SERVICE_NO_CHANGE, // error control: no change 
  438.         NULL,              // binary path: no change 
  439.         NULL,              // load order group: no change 
  440.         NULL,              // tag ID: no change 
  441.         NULL,              // dependencies: no change 
  442.         NULL,              // account name: no change
  443. NULL, // password: no change
  444. NULL)) //displayname 
  445.     {
  446.     }
  447.     else 
  448. {
  449. m_list.SetItemText(x, 3, "自动");        
  450.     UnlockServiceDatabase(sclLock); 
  451.     CloseServiceHandle(service); 
  452. CloseServiceHandle(scm);
  453. }
  454. void CServicePage::OnServiceManager() 
  455. {
  456. // TODO: Add your command handler code here
  457. EnablePriv();
  458. char ServerName[MAX_PATH]=" ";
  459. int x=m_list.GetSelectionMark();
  460. m_list.GetItemText(x,0,ServerName,MAX_PATH);
  461. SC_HANDLE scm;
  462.     SC_HANDLE service;
  463. if((scm=OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS))==NULL)
  464. {
  465. return;
  466. }
  467.     service=OpenService(scm, ServerName, SERVICE_ALL_ACCESS);
  468. if(!service)
  469. {
  470. if(ERROR_SERVICE_DOES_NOT_EXIST == GetLastError())
  471. {
  472. MessageBox("指定服务不存在!n", "错误", MB_OK|MB_ICONERROR);
  473. CloseServiceHandle(scm);
  474. return;
  475. }
  476. }
  477.     SC_LOCK sclLock; 
  478.     DWORD  dwStartType; 
  479.     sclLock = LockServiceDatabase(scm); 
  480.     if (sclLock == NULL) 
  481.     { 
  482. DWORD dwErr = GetLastError();
  483.         if (dwErr == ERROR_SERVICE_DATABASE_LOCKED) 
  484. {
  485. CloseServiceHandle(scm);
  486. return;
  487. }
  488. if(dwErr == ERROR_INVALID_HANDLE)
  489. {
  490. CloseServiceHandle(scm);
  491. return;
  492. }
  493. if(dwErr == ERROR_ACCESS_DENIED)
  494. {
  495. CloseServiceHandle(scm);
  496. return;
  497. }
  498. else
  499. {
  500. return;
  501. }   
  502.         
  503.     } 
  504.     dwStartType = SERVICE_DEMAND_START;
  505.     if (! ChangeServiceConfig( 
  506.         service,        // handle of service 
  507.         SERVICE_NO_CHANGE, // service type: no change 
  508.         dwStartType,       // change service start type 
  509.         SERVICE_NO_CHANGE, // error control: no change 
  510.         NULL,              // binary path: no change 
  511.         NULL,              // load order group: no change 
  512.         NULL,              // tag ID: no change 
  513.         NULL,              // dependencies: no change 
  514.         NULL,              // account name: no change
  515. NULL, // password: no change
  516. NULL)) //displayname 
  517.     {
  518.     }
  519.     else 
  520. {
  521. m_list.SetItemText(x, 3, "手动");
  522. }
  523.     UnlockServiceDatabase(sclLock); 
  524.     CloseServiceHandle(service); 
  525. CloseServiceHandle(scm);
  526. }
  527. void CServicePage::OnServiceDisable() 
  528. {
  529. // TODO: Add your command handler code here
  530. EnablePriv();
  531. char ServerName[100]=" ";
  532. int x=m_list.GetSelectionMark();
  533. m_list.GetItemText(x,0,ServerName,100);
  534. SC_HANDLE scm;
  535.     SC_HANDLE service;
  536. if((scm=OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS))==NULL)
  537. {
  538. return;
  539. }
  540.     service=OpenService(scm,ServerName,SERVICE_ALL_ACCESS);
  541. if(!service)
  542. {
  543.    CloseServiceHandle(scm);
  544.    return;
  545. }
  546.     SC_LOCK sclLock; 
  547.     DWORD  dwStartType; 
  548.     sclLock = LockServiceDatabase(scm); 
  549.     if (sclLock == NULL) 
  550.     { 
  551.         DWORD dwErr = GetLastError();
  552.         if (dwErr == ERROR_SERVICE_DATABASE_LOCKED) 
  553. {
  554. CloseServiceHandle(scm);
  555. return;
  556. }
  557. if(dwErr == ERROR_INVALID_HANDLE)
  558. {
  559. CloseServiceHandle(scm);
  560. return;
  561. }
  562. if(dwErr == ERROR_ACCESS_DENIED)
  563. {
  564. CloseServiceHandle(scm);
  565. return;
  566. }
  567. else
  568. {
  569. return;
  570. }          
  571.     } 
  572.     dwStartType = SERVICE_DISABLED;
  573.     if (! ChangeServiceConfig( 
  574.         service,        // handle of service 
  575.         SERVICE_NO_CHANGE, // service type: no change 
  576.         dwStartType,       // change service start type 
  577.         SERVICE_NO_CHANGE, // error control: no change 
  578.         NULL,              // binary path: no change 
  579.         NULL,              // load order group: no change 
  580.         NULL,              // tag ID: no change 
  581.         NULL,              // dependencies: no change 
  582.         NULL,              // account name: no change
  583. NULL, // password: no change
  584. NULL)) //displayname 
  585.     {
  586.         MessageBox("修改配置错误!n", "错误", MB_OK|MB_ICONERROR); 
  587.     }
  588.     else 
  589. {
  590. m_list.SetItemText(x, 3, "禁用");
  591.     }
  592.     UnlockServiceDatabase(sclLock); 
  593.     CloseServiceHandle(service); 
  594. CloseServiceHandle(scm);
  595. }
  596. void CServicePage::OnServiceProperties() 
  597. {
  598. // TODO: Add your command handler code here
  599. EnablePriv();
  600. char AppPath[100]=" ";
  601. char Path[MAX_PATH];
  602. int x=m_list.GetSelectionMark();
  603. m_list.GetItemText(x,4,AppPath,100);
  604. SHELLEXECUTEINFO sei;
  605. memset(Path, 0, MAX_PATH);
  606. GoTo->ParseString(AppPath, Path);
  607. ZeroMemory(&sei,sizeof(sei));
  608. sei.cbSize = sizeof(sei);
  609. sei.lpFile = Path;
  610. sei.lpVerb = _T("properties");
  611. sei.fMask  = SEE_MASK_INVOKEIDLIST;
  612. sei.nShow  = SW_SHOWNORMAL;
  613. ShellExecuteEx(&sei); 
  614. }