EnumServicesStatus

c++ 获取系统服务 <br />#include "StdAfx.h" #include <windows.h> #include <iostream.h> void main() { int menu = 0; while (cin >> menu) { if(menu == 1) { SC_HANDLE SCMan = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); //打开系统服务控制器 if(SCMan == NULL) 阅读详情

EnumServicesStatus

The EnumServicesStatus function enumerates services in the specified service control manager database. The name and status of each service are provided.

This function has been superseded by the EnumServicesStatusEx function. It returns the same information EnumServicesStatus returns, plus the process identifier and additional information for the service. In addition, EnumServicesStatusEx enables you to enumerate services that belong to a specified group.

BOOL EnumServicesStatus(
  SC_HANDLE hSCManager,
  DWORD dwServiceType,
  DWORD dwServiceState,
  LPENUM_SERVICE_STATUS lpServices,
  DWORD cbBufSize,
  LPDWORD pcbBytesNeeded,
  LPDWORD lpServicesReturned,
  LPDWORD lpResumeHandle
);
Parameters
hSCManager
[in] Handle to the service control manager database. This handle is returned by the OpenSCManager function, and must have the SC_MANAGER_ENUMERATE_SERVICE access right. For more information, see Service Security and Access Rights.
dwServiceType
[in] Type of services to enumerate. This parameter can be one or more of the following values.
ValueMeaning
SERVICE_DRIVER
0x0000000B
Enumerates services of type SERVICE_KERNEL_DRIVER and SERVICE_FILE_SYSTEM_DRIVER.
SERVICE_WIN32
0x00000030
Enumerates services of type SERVICE_WIN32_OWN_PROCESS and SERVICE_WIN32_SHARE_PROCESS.
dwServiceState
[in] State of the services to be enumerated. This parameter can be one of the following values.
ValueMeaning
SERVICE_ACTIVE
0x00000001
Enumerates services that are in the following states: SERVICE_START_PENDING, SERVICE_STOP_PENDING, SERVICE_RUNNING, SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, and SERVICE_PAUSED.
SERVICE_INACTIVE
0x00000002
Enumerates services that are in the SERVICE_STOPPED state.
SERVICE_STATE_ALL
0x00000003
Combines the following states: SERVICE_ACTIVE and SERVICE_INACTIVE.
lpServices
[out] Pointer to a buffer that contains an array of ENUM_SERVICE_STATUS structures that receive the name and service status information for each service in the database. The buffer must be large enough to hold the structures, plus the strings to which their members point.

The maximum size of this array is 64K bytes. To determine the required size, specify NULL for this parameter and 0 for the cbBufSize parameter. The function will fail and GetLastError will return ERROR_INSUFFICIENT_BUFFER. The pcbBytesNeeded parameter will receive the required size..

cbBufSize
[in] Size of the buffer pointed to by the lpServices parameter, in bytes.
pcbBytesNeeded
[out] Pointer to a variable that receives the number of bytes needed to return the remaining service entries, if the buffer is too small.
lpServicesReturned
[out] Pointer to a variable that receives the number of service entries returned.
lpResumeHandle
[in, out] Pointer to a variable that, on input, specifies the starting point of enumeration. You must set this value to zero the first time this function is called. On output, this value is zero if the function succeeds. However, if the function returns zero and the GetLastError function returns ERROR_MORE_DATA, this value is used to indicate the next service entry to be read when the function is called to retrieve the additional data.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

The following error codes can be set by the service control manager. Other error codes can be set by the registry functions that are called by the service control manager.

Return codeDescription
ERROR_ACCESS_DENIEDThe handle does not have the SC_MANAGER_ENUMERATE_SERVICE access right.
ERROR_INVALID_HANDLEThe specified handle is invalid.
ERROR_INVALID_PARAMETERA parameter that was specified is invalid.
ERROR_MORE_DATAThere are more service entries than would fit into the lpServices buffer. The actual number of service entries written to lpServices is returned in the lpServicesReturned parameter. The number of bytes required to get the remaining entries is returned in the pcbBytesNeeded parameter. The remaining services can be enumerated by additional calls to EnumServicesStatus with the lpResumeHandle parameter indicating the next service to read.
Requirements
ClientRequires Windows XP, Windows 2000 Professional, or Windows NT Workstation.
ServerRequires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header

Declared in Winsvc.h; include Windows.h.

Library

Link to Advapi32.lib.

DLLRequires Advapi32.dll.
Unicode

Implemented as EnumServicesStatusW (Unicode) and EnumServicesStatusA (ANSI).

[Win32] SCManager 服务控制管理器API(2) 在上一篇博文“[Win32] SCManager 服务控制管理器API(1)”中(地址:http://blog.youkuaiyun.com/zuishikonghuan/article/details/47803033),讲到了打开服务控制管理器、创建服务、打开服务、删除服务、获取服务状态、启动服务、发送控制码,这一篇继续。 9。枚举服务 阅读详情

相关推荐

WINDOWS任务管理器

MFC VC++6.0 WINDOWS下的任务管理器~自己编的供参考~

windows c++ 输出所有服务列表,并判断是否是开机启动项

std::cout << "是否为自动启动:" << ((lpServices[i].ServiceStatusProcess.dwServiceType & SERVICE_AUTO_START)?std::wcout << "服务名:" << lpServices[i].lpServiceName << std::endl;错误代码:" << GetLastError() << std::endl;std::cout << "所有的服务列表:" << std::endl;// 获取服务状态信息。

jijie_ming的博客 293

根据服务名取进程ID

(DELPHI7自带的WinSvc单元没有定义MSDN新增的几个函数 QueryServiceStatusEx, EnumServicesStatusEx 等),附带了WinSvc单元新增的这几个函数的定义

C++枚举系统服务

突然想仿照XueTr中的服务管理写个小程序。 hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 打开服务管理器,SC_MANAGER_ALL_ACCESS的权限有点大,懒得查了。 EnumServicesStatusEx枚举服务,也可以获得Driver的服务,需要注意的是这个函数的缓冲区是不固定的,贸然使用一个过大或者过小的缓冲

SomeTimes 5523

设置系统服务状态,禁用服务,启动服务,枚举服务的例子

枚举系统服务,将系统服务的信息显示在一个listview中,包含服务路径名称,描述,服务名等信息 可设置服务状态,启动,停止服务

第三篇:学习InternVL2.0(探讨代码之训练模块版)

InternVL2的训练模块

qq_69051120的博客 1244

windows服务管理操作

服务程序是windows上重要的一类程序,它们虽然不与用户进行界面交互,但是它们对于系统有着重要的意义。windows上为了管理服务程序提供了一个特别的程序:服务控制管理程序,系统上关于服务控制管理的API基本上都与这个程序打交道。下面通过对服务程序的操作来说明这些API函数 获取系统服务的信息 在windows系统中有专门用来存储服务信息的数据库,而获取系统服务信息主要是通过在这样的数据库中

Masimaro的专栏 3447

深度学习-176-知识图谱技术之langchain与neo4j的嵌入向量Neo4jVector

使用Neo4jVector将输入的文档向量化,并创建向量索引,然后进行语义检索。

qq_20466211的博客 440

C/C++ 开发SCM服务管理组件

SCM(Service Control Manager)服务管理器是 Windows 操作系统中的一个关键组件,负责管理系统服务的启动、停止和配置。服务是一种在后台运行的应用程序,可以在系统启动时自动启动,也可以由用户或其他应用程序手动启动。本篇文章中,我们将通过使用 Windows 的服务管理器(SCM)提供的API接口,实现一个简单的服务管理组件的编写。

微软技术分享 5947

ios开发拒绝“玄学”Crash:从循环引用到脏内存,构建你的系统性排查思维模型

你申请了内存,写了数据,这块内存就是脏的。系统无法直接回收它,除非你显式释放,或者系统把它 swap 出去(但在 iOS 上,Compressed Memory 机制虽然能压缩,但不会像桌面系统那样频繁 swap 到磁盘,一旦压缩内存也撑不住,你也得挂)。所以,排查 OOM 的核心心法只有一条:不要问“哪里漏了”,要问“每一刻,留在这个页面上的内存,凭什么必须在这里?一旦内存水位线逼近阈值(不同机型不同,老机器可能 600MB 就危,新机器能抗 1.5GB),系统发个警告。

大模型大数据攻城狮的专栏 724

EDEM-fluent耦合时出现的问题及摸索出的解决办法及DPM颗粒信息导出

EDEM-fluent耦合时出现的问题及摸索出的解决办法及DPM颗粒信息导出

zheaa的博客 5748

编程控制Windows服务

这一篇我们来介绍如何编程控制Windows服务,主要介绍两方面的内容,一是枚举系统所有服务,二是编程对服务进行控制,下面我们分别进行讲解。 枚举服务 我们主要用到两个函数:EnumServicesStatus和QueryServiceConfig,其中函数EnumServicesStatus可以获取系统中所有服务的基本信息,包括服务名称、显示名称、当前状态,如果想获取更加详细的信息,就需要Qu

Armstronghappy的专栏 1200

【CSP-S 提高组】考试大纲集合

【CSP-S提高组】考试大纲集合

weixin_42596089的博客 7253

【PyTorch项目实战】图像分类与识别:手写数字识别(MNIST)、普适物体识别(CIFAR-10)

主要介绍了两个经典的实战项目:(1)基于 MNIST 数据集的手写数字识别(2)基于 CIFAR-10 数据集进行图像分类

📷 图像处理践行者 | 传统算法 · 深度学习 · 多模态 | 分享实战经验与技术洞见,探索从像素到智能的无限可能。 4400

Unreal5.6从入门到精通之 如何实现MetaHuman数字人

本文介绍了使用HYPER3D-ChatAvatar网站生成3D头部模型,并导入Unreal Engine制作数字人的完整流程。首先上传照片生成头部模型(约2分钟),设置参数后下载模型文件。然后在UE5.6中创建项目,激活MetaHuman插件,导入头部模型并调整肤色、面部特征和身体模板。通过MetaHuman Creator组装数字人蓝图,支持添加音频/视频动画功能。关键步骤包括:取消Rigging选项节省时间、切换英文模式避免材质问题、使用Live Link Face应用实现面部捕捉等。整个流程约需5-1

TxNet 1342

Windows XP下Service的编程入门[2]

Windows XP下Service的编程入门[2]// _dse.cpp : Defines the entry point for the console application.// 作者: 秋镇菜// E-mail: cyin8@msn.com// 本程序很简单#include "stdafx.h"#include "windows.h"int main(int argc, char* a

小发猫 1562

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

ENUM_SERVICE_STATUS

ENUM_SERVICE_STATUSThe ENUM_SERVICE_STATUS structure is used by the EnumDependentServices and EnumServicesStatus functions to return the name of a service in a service control manager database and to

小发猫 1885

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

dll调用

调用AdvAPI32.Dll中的EnumServicesStatus函数。运行时出现“未将对象引用设置到对象的实例”错误?

biyusr的专栏 384

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

服务控制程序

点击打开原文链接一:服务控制程序概要服务控制程序的编写与标准的Windows应用程序无异,它要用到服务管理函数,如:OpenSCManager、OpenService、QueryServiceConfig、StartService、QueryServiceStatus、ControlService等;它都在系统的advapi32.dll中实现。在使用SCM的函数时,SCP必须要首先调用OpenSC...

mpp_king的博客 1106

C++ 获取Windows服务列表

#include <windows.h> #include <iostream> #define MAX_SERVICE_SIZE 1024 * 64 #define MAX_QUERY_SIZE 1024 * 8 int main(void) { do { SC_HANDLE SCMan = OpenSCMana...

weixin_30614109的博客 1402

C++ (Windows Service)服务编程 - 服务管理

例子源码挂在github上,如有需要请clone : https://github.com/mox9378/Cpp-Simple-Windows-Service-Example 欢迎 C++/Python 的朋友一起交流学习, My QQ Number: 2303186535 以下附上相关结构体和函数的介绍: Struct SERVICE_STATUS结构定义了服务的运行状态/...

weixin_30369041的博客 604

Windows服务打造(二)

1. 欲访问windows服务,得调用Windows API OpenSCManager(...)访问服务数据库,查看MSDN中DOpenSCManager函数如下: SC_HANDLE WINAPI OpenSCManager( __in LPCTSTR lpMachineName, __in LPCTSTR lpDatabaseName,

qq_27011361的博客 299

控制服务程序

控制服务程序枚举、启动、停止服务程序,使用OpenSCManager、EnumServicesStatus、OpenService、ControlService、StartService等API。 CEnumServiceDlg.cppBEGIN_MESSAGE_MAP(CEnumServiceDlg, CDialogEx) ON_WM_PAINT() ON_WM_QUERYDRA

yangyang031213的博客 493
上一篇: EnumServicesStatusEx
下一篇: GetServiceKeyName
普通网友
博客等级 码龄22年 1万+粉丝 3156原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值