CreateService

windows CreateService函数注册服务的删除(getlasterror函数 1703错误码解决) 在调用了CreateService函数之后,我生成了一个 asystem的服务。再次执行,用getlasterror函数得到```1073``错误码->指定的服务已经存在,无法创建。 GetSystemDirectory(chSysPath,sizeof(chSysPath));//取系统目录 strcat(chSysPath,"\\asystem.exe");//将scvhost.exe拼接到系统目录 LPCTSTR lpszBinaryPathName=strDir; schServi. 阅读详情

CreateService

The CreateService function creates a service object and adds it to the specified service control manager database.

SC_HANDLE CreateService(
  SC_HANDLE hSCManager,
  LPCTSTR lpServiceName,
  LPCTSTR lpDisplayName,
  DWORD dwDesiredAccess,
  DWORD dwServiceType,
  DWORD dwStartType,
  DWORD dwErrorControl,
  LPCTSTR lpBinaryPathName,
  LPCTSTR lpLoadOrderGroup,
  LPDWORD lpdwTagId,
  LPCTSTR lpDependencies,
  LPCTSTR lpServiceStartName,
  LPCTSTR lpPassword
);
Parameters
hSCManager
[in] Handle to the service control manager database. This handle is returned by the OpenSCManager function and must have the SC_MANAGER_CREATE_SERVICE access right. For more information, see Service Security and Access Rights.
lpServiceName
[in] Pointer to a null-terminated string that specifies the name of the service to install. The maximum string length is 256 characters. The service control manager database preserves the case of the characters, but service name comparisons are always case insensitive. Forward-slash (/) and back-slash (/) are invalid service name characters.
lpDisplayName
[in] Pointer to a null-terminated string that contains the display name to be used by user interface programs to identify the service. This string has a maximum length of 256 characters. The name is case-preserved in the service control manager. Display name comparisons are always case-insensitive.
dwDesiredAccess
[in] Access to the service. Before granting the requested access, the system checks the access token of the calling process. For a list of values, see Service Security and Access Rights.
dwServiceType
[in] Service types. This parameter can be one of the following values.
ValueMeaning
SERVICE_FILE_SYSTEM_DRIVER
0x00000002
File system driver service.
SERVICE_KERNEL_DRIVER
0x00000001
Driver service.
SERVICE_WIN32_OWN_PROCESS
0x00000010
Service that runs in its own process.
SERVICE_WIN32_SHARE_PROCESS
0x00000020
Service that shares a process with one or more other services. For more information, see Service Programs.

If you specify either SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, and the service is running in the context of the LocalSystem account, you can also specify the following value.

ValueMeaning
SERVICE_INTERACTIVE_PROCESS
0x00000100
The service can interact with the desktop.

For more information, see Interactive Services.

dwStartType
[in] Service start options. This parameter can be one of the following values.
ValueMeaning
SERVICE_AUTO_START
0x00000002
A service started automatically by the service control manager during system startup.
SERVICE_BOOT_START
0x00000000
A device driver started by the system loader. This value is valid only for driver services.
SERVICE_DEMAND_START
0x00000003
A service started by the service control manager when a process calls the StartService function.
SERVICE_DISABLED
0x00000004
A service that cannot be started. Attempts to start the service result in the error code ERROR_SERVICE_DISABLED.
SERVICE_SYSTEM_START
0x00000001
A device driver started by the IoInitSystem function. This value is valid only for driver services.
dwErrorControl
[in] Severity of the error, and action taken, if this service fails to start. This parameter can be one of the following values.
ValueMeaning
SERVICE_ERROR_CRITICAL
0x00000003
The startup program logs the error, if possible. If the last-known-good configuration is being started, the startup operation fails. Otherwise, the system is restarted with the last-known good configuration.
SERVICE_ERROR_IGNORE
0x00000000
The startup program logs the error but continues the startup operation.
SERVICE_ERROR_NORMAL
0x00000001
The startup program logs the error and puts up a message box pop-up but continues the startup operation.
SERVICE_ERROR_SEVERE
0x00000002
The startup program logs the error. If the last-known-good configuration is being started, the startup operation continues. Otherwise, the system is restarted with the last-known-good configuration.
lpBinaryPathName
[in] Pointer to a null-terminated string that contains the fully qualified path to the service binary file. If the path contains a space, it must be quoted so that it is correctly interpreted. For example, "d://my share//myservice.exe" should be specified as "/"d://my share//myservice.exe/"".

The path can also include arguments for an auto-start service. For example, "d://myshare//myservice.exe arg1 arg2". These arguments are passed to the service entry point (typically the main function).

lpLoadOrderGroup
[in] Pointer to a null-terminated string that names the load ordering group of which this service is a member. Specify NULL or an empty string if the service does not belong to a group.

The startup program uses load ordering groups to load groups of services in a specified order with respect to the other groups. The list of load ordering groups is contained in the following registry value:

HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control/ServiceGroupOrder

lpdwTagId
[out] Pointer to a variable that receives a tag value that is unique in the group specified in the lpLoadOrderGroup parameter. Specify NULL if you are not changing the existing tag.

You can use a tag for ordering service startup within a load ordering group by specifying a tag order vector in the following registry value:

HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control/GroupOrderList

Tags are only evaluated for driver services that have SERVICE_BOOT_START or SERVICE_SYSTEM_START start types.

lpDependencies
[in] Pointer to a double null-terminated array of null-separated names of services or load ordering groups that the system must start before this service. Specify NULL or an empty string if the service has no dependencies. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group.

You must prefix group names with SC_GROUP_IDENTIFIER so that they can be distinguished from a service name, because services and service groups share the same name space.

lpServiceStartName
[in] Pointer to a null-terminated string that specifies the name of the account under which the service should run. If the service type is SERVICE_WIN32_OWN_PROCESS, use an account name in the form DomainName/UserName. The service process will be logged on as this user. If the account belongs to the built-in domain, you can specify ./ UserName.

If this parameter is NULL, CreateService uses the LocalSystem account. If the service type specifies SERVICE_INTERACTIVE_PROCESS, the service must run in the LocalSystem account.

If this parameter is NT AUTHORITY/LocalService, CreateService uses the LocalService account. If the parameter is NT AUTHORITY/NetworkService, CreateService uses the NetworkService account.

Windows NT:  If the service type is SERVICE_WIN32_SHARE_PROCESS, you must specify the LocalSystem account. On later versions of Windows, a shared process can run as any user.

If the service type is SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER, the name is the driver object name that the system uses to load the device driver. Specify NULL if the driver is to use a default object name created by the I/O system.

lpPassword
[in] Pointer to a null-terminated string that contains the password to the account name specified by the lpServiceStartName parameter. Specify an empty string if the account has no password or if the service runs in the LocalService, NetworkService, or LocalSystem account. For more information, see Service Record List.

Passwords are ignored for driver services.

Return Values

If the function succeeds, the return value is a handle to the service.

If the function fails, the return value is NULL. 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 to the SCM database does not have the SC_MANAGER_CREATE_SERVICE access right.
ERROR_CIRCULAR_DEPENDENCYA circular service dependency was specified.
ERROR_DUPLICATE_SERVICE_NAMEThe display name already exists in the service control manager database either as a service name or as another display name.
ERROR_INVALID_HANDLEThe handle to the specified service control manager database is invalid.
ERROR_INVALID_NAMEThe specified service name is invalid.
ERROR_INVALID_PARAMETERA parameter that was specified is invalid.
ERROR_INVALID_SERVICE_ACCOUNTThe user account name specified in the lpServiceStartName parameter does not exist.
ERROR_SERVICE_EXISTSThe specified service already exists in this database.
Remarks

The CreateService function creates a service object and installs it in the service control manager database by creating a key with the same name as the service under the following registry key:

HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services

Information specified by CreateService, ChangeServiceConfig, and ChangeServiceConfig2 is saved as values under this key. The following are examples of values stored for a service.

ValueDescription
DependOnGroupLoad-ordering groups on which this service depends, as specified by lpDependencies.
DependOnServiceServices on which this service depends, as specified by lpDependencies.
DescriptionDescription specified by ChangeServiceConfig2 .
DisplayNameDisplay name specified by lpDisplayName.
ErrorControlError control specified by dwErrorControl.
FailureActionsFailure actions specified by ChangeServiceConfig2 .
GroupLoad ordering group specified by lpLoadOrderGroup. Note that setting this value can override the setting of the DependOnService value.
ImagePathName of binary file, as specified by lpBinaryPathName.
ObjectNameAccount name specified by lpServiceStartName.
StartWhen to start service, as specified by dwStartType.
TagTag identifier specified by lpdwTagId.
TypeService type specified by dwServiceType.

Setup programs and the service itself can create additional subkeys for service-specific information.

The returned handle is only valid for the process that called CreateService. It can be closed by calling the CloseServiceHandle function.

If you are creating services that share a process, avoid calling functions with process-wide effects, such as ExitProcess. In addition, do not unload your service DLL.

Example Code

For an example, see Installing a Service.

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 CreateServiceW (Unicode) and CreateServiceA (ANSI).

视频编解码——视频编解码器工作原理 目录什么是视频编解码器为什么需要视屏编解码器视频编码器与数字视频容器时评编码器的历史 什么是视频编解码器 简单来说就是用于压缩或解压数字视频的软件或硬件 编码是信息从一种形式或格式转换为另一种形式的过程,解码是编码的反向。 适用于视频 编码是将视频、音频的原始格式的文件通过压缩技术转换成另一种格式(视频如h.264,h.265,m-jpeg等)。 解码是编码的反向过程。应用中,一般是将h.264,h.265格式数据解码成如YUV格式裸流交给显示器显示。 为什么需要视屏编解码器 需要在有限的带宽或存储空间 阅读详情

相关推荐

浅谈武术擂台格斗机器人大赛

武术擂台机器人赛是工科类专业的一个跨学科的竞赛项目,它涵盖了机械结构、硬件电路和计算机程序等技术领域。笔者在校期间有幸参加过四次这样的比赛,有成功也有失败,对此深有感悟。本文仅为个人观点,有说得不对的地方,望积极指出,希望能帮助到有需要的人。

weixin_43811044的博客 1万+

CreateService / SC 创建自启动服务

下面的代码创建了一个服务,然后把自己复制到C盘下,通过服务实现开机自启动。 如果要卸载这个服务,只需执行一下命令: sc delete AutoStartServiceDemo // AutoStartServiceDemo.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <windows.h> char lpszServiceName[MAX_PATH]

hambaga的博客 4506

【iOS开发】dyld: Symbol not found: ___chkstk_darwin 问题解决

【iOS开发】dyld: Symbol not found: ___chkstk_darwin 问题解决 Xcode 13.2.1 运行到iOS12.x版本上崩溃报错如下:dyld: Symbol not found: ___chkstk_darwin dyld: Symbol not found: ___chkstk_darwin Referenced from: /private/var/containers/Bundle/Application/A424CEFD-51DB-450E-9D62-B8

wm9028的专栏 6566

[SC] CreateService 失败 1073: 指定的服务已存在。

以设置MongoDB服务为系统服务,为例: sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\4.2\mongod.cfg\"" DisplayName= "MongoDB" start= "auto" 在创建系统服务时,提示: [SC] CreateService 失败 1

白骨梦儿 1万+

高光谱图像处理和分析软件(包含雷尼绍Renishaw wdf 文件导入解析功能)

是一款基于微软windows操作系统的多传感器成像工具,用于处理和分析高光谱图像。它是一个模块化的系统,由一个基本的引擎,一个图形用户界面,一个化学计量工具箱和可选的用户提供的模块组成。它支持最重要的光谱成像技术,如UV/Vis、红外、拉曼、太赫兹、光发射/吸收和质谱。除此之外,还允许用户将高光谱图像与物理属性图和传统高分辨率彩色照片合并在一起 链接:https://pan.baidu.com/s/1ruQ5YSh5_ZS9wx_V3Q5Oow 提取码:qdx0 ...

业余程序员小徐的博客 8073

保姆级教程:用OpenCV的calibrateHandEye()搞定机器人手眼标定(附Python代码)

本文详细介绍了如何使用OpenCV的calibrateHandEye()函数完成机器人手眼标定,解决机械臂与相机坐标系对齐问题。教程涵盖从基础原理、数据采集到Python代码实现的完整流程,特别适合需要精确视觉引导的机器人应用开发。通过手眼标定,可确保机械臂准确抓取相机检测到的目标物体。

weixin_33712987的博客 517

关于CreateService的一个大问题:权限问题

CreateService的最后两个参数是该服务从属的帐号(用户名,密码)。如果用null填的话,就会用默认帐号 LocalSystem。此帐号有很大的访问限制,在这个帐号下的服务程序不能访问其他帐号下的很多东西。而且在此帐号内生成的共享对象(shared object),其他帐号下的应用程序也不能访问(比如,我用administrator登入系统的,但是服务的帐号却是LocalSystem,则在

mac_forward的专栏 3760

跟着Synopsys报告,一步步拆解车规芯片FMEDA计算(含公式与避坑点)

本文详细解析了车规芯片FMEDA计算的全流程,基于Synopsys报告拆解实战指南,涵盖基础失效率建模、安全机制效能评估及安全指标合成等关键步骤。通过公式解析、数据准备清单和避坑点分享,帮助工程师掌握ISO26262标准下的硬件量化分析技术,提升车载系统设计可靠性。

weixin_30460489的博客 195

【原创】驱动加载之CreateService

SC_HANDLE WINAPI CreateService( _In_ SC_HANDLE hSCManager, _In_ LPCTSTR lpServiceName, _In_opt_ LPCTSTR lpDisplayName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwServiceType, _In_ DWORD dwStartT...

weixin_34041003的博客 799

Cadence DSP 算子开发实战:从入门到精通

本文详细介绍了Cadence DSP算子开发的实战技巧,从入门基础到高级优化。内容涵盖DSP架构特性、内存管理、分块计算策略、SIMD指令优化等核心知识,并提供了性能调优和调试的实用技巧,帮助开发者快速掌握Cadence DSP开发精髓,提升图像处理等计算密集型任务的开发效率。

weixin_29278805的博客 437

PT:pt write_change to innovus 脚本

我正在「拾陆楼」和朋友们讨论有趣的话题,你⼀起来吧?

m0_61544122的博客 1527

StartService()返回2 -- 坑爹的CreateService()

用SCM加载驱动CreateService()的lpBinaryPathName 使用的是相对路径"mydrv.sys",发现后面StartService()总是返回0x2(系统找不到指定的文件), 不明白为什么, 总觉得文件路径应该不是问题, 因为前两天也是这个相对路径, 而且成功了,而且如果路径不对,CreateService()应该返回NULL啊, 郁闷了很长时间,终于写成完全路径格式,没想...

weixin_30908941的博客 809

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

解决system error caught. error code=1073, m essage = CreateService failed: unknown error

安装redis报错信息:[9204] 15 Jun 11:41:44.516 # HandleServiceCommands: system error caught. error code=1073, message = CreateService failed: unknown error解决方法:http://www.yayihouse.com/yayishuwu/chapter/1297...

qq_30908729的博客 9700

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

CreateService 服务程序的服务依赖

写的一个服务依赖于MySQL,启动的时候总是说"错误1075:依存服务不存在, 或已标记为删除",但是MySQL已经在运行,打开注册表HKEY_LOCAL_MACHINE\System\CurrentControlSet\services,发现自己写的服务的DependOnService字段的值里面除了MySQL之外,外面跟了一串乱码!删掉乱码也没用,不是能随便改的,DependOnServic

fighton的专栏 4008

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

以特定用户createservice并且openservice过程

最近做项目碰到这个问题,要以某个特定额用户建立一个service并启动起来,service是建好了,但是启动的时候出现logon错误。看起来像是密码不对,其实是用户没有拿到logon的权限,没有很具体看,在stackoverflow上找到解决方案,希望对别人有所帮助。 #define UNICODE #include #include #include #pragma comment

Beck_Dai的专栏 1105

load_sysfile;CreateService

// test7.cpp : Defines the entry point for the console application. // #include "stdafx.h" bool load_sysfile(char *theDriverName) { char aPath[1024]; char aCurrentDirectory[515];

autumn20080101的专栏 911

Error installing a service: CreateService: Win32 error 1726

在windows上配置cygwin出现错误:Error installing a service: CreateService:  Win32 error 1726 Win32 error 1726指的是远程过程调用失败 解决方案:关闭本地的防火墙 启动成功

murongliuhuang的专栏 1999

用VC++建立Service服务应用程序

用VC++建立Service服务应用程序 作者:李佳颖(niying) 下载源代码    本文主要介绍了 OpenSCManager、CreateService、OpenService、ControlService、DeleteService、 RegisterServiceCtrlHandler、SetServiceStatus、StartServiceCt

todototry的专栏 1502

nt驱动CreateService创建SERVICE_BOOT_START级别服务报错87

在网上看了一个关于nt驱动安装卸载的例子,于是自己写了需要SERVICE_BOOT_START级别启动的驱动,但是安装的时候报错了,错误码是87。但是我只是改了一个级别而已,没道理会出错的。然后我只是简单的把驱动文件复制到C:\Windows\System32\Drivers目录。再执行一遍,居然成功了。不改级别的时候,测试过,路径不需要指定。可能因为这个级别的特殊性吧。...

youyudexiaowangzi的专栏 1600

关于创建windows服务

1.创建本地账号服务,实例代码 VOID Install(TCHAR* pPath, TCHAR* pName) {   SC_HANDLE schSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_CREATE_SERVICE);  if (schSCManager==0)  {   long nError = GetLastE

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

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值