⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control.c

📁 一个类似windows
💻 C
字号:
/*
 * 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;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -