在C ++中将可执行文件作为服务运行 [英] Run an executable as service in C++

查看:93
本文介绍了在C ++中将可执行文件作为服务运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MSVS2013创建了一个Win32Console应用程序,该应用程序已成功编译.现在,我尝试使用CreateService创建服务,并且将二进制路径设置为上述生成的可执行文件的路径.尽管我能够创建该服务,但无法使用StartService启动它.每次都会引发错误代码1053.我尝试使用sc.exe,并且还尝试从Services手动启动服务.显示相同的错误.我现在该如何解决?

I created a Win32Console application using MSVS2013 and it was compiled successfully. Now I tried creating a service using CreateService and binary path was set to the path of the above produced executable. Though I was able to create the service, I cannot start it using StartService. The error code 1053 is thrown each time. I tried using sc.exe and also tried to start the service manually from Services. The same error is shown. How can I solve it now?

推荐答案

您必须创建此处是示例 .
如果要执行非服务应用程序,则可以使用 psexec .

You must create a ServiceMain.
Here is a sample.
If you want to execute a non-service application you can use psexec.

这篇关于在C ++中将可执行文件作为服务运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆