一个类似windows

源代码在线查看: control.c

软件大小: 26417 K
上传用户: hudun2006
关键词: windows
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*
				 * COPYRIGHT:   See COPYING in the top level directory
				 * PROJECT:     ReactOS SC utility
				 * FILE:        subsys/system/sc/control.c
				 * PURPOSE:     control ReactOS services
				 * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
				 * REVISIONS:
				 *           Ged Murphy 20/10/05 Created
				 *
				 */
				
				#include "sc.h"
				
				/*
				 * handles the following commands:
				 * control, continue, interrogate, pause, stop
				 */
				
				BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args)
				{
				    SC_HANDLE hSc;
				    SERVICE_STATUS Status;
				
				#ifdef SCDBG    
				    /* testing */
				    _tprintf(_T("service to control - %s\n\n"), ServiceName);
				    _tprintf(_T("command - %lu\n\n"), Control);
				    _tprintf(_T("Arguments :\n"));
				    while (*Args)
				    {
				        printf("%s\n", *Args);
				        Args++;
				    }
				#endif /* SCDBG */
				
				    hSc = OpenService(hSCManager, ServiceName,
				                      SERVICE_INTERROGATE | SERVICE_PAUSE_CONTINUE |
				                      SERVICE_STOP | SERVICE_USER_DEFINED_CONTROL |
				                      SERVICE_QUERY_STATUS);
				
				    if (hSc == NULL)
				    {
				        _tprintf(_T("openService failed\n"));
				        ReportLastError();
				        return FALSE;
				    }
				
				    if (! ControlService(hSc, Control, &Status))
				    {
						_tprintf(_T("[SC] controlService FAILED %lu:\n\n"), GetLastError());
				        ReportLastError();
				        return FALSE;
				    }
				
				    CloseServiceHandle(hSc);
				    
				    /* print the status information */
				    
				    return TRUE;
				
				}
							

相关资源