从 VB6 到 .net 服务的 ExecuteCommand
在 VB.net 中,我可以在 Windows 服务上执行自定义命令:
桌面:
Const SmartShutdown As Integer = 12
Dim myService As New ServiceController("SampleService")
myService.ExecuteCommand(SmartShutdown)
Windows 服务:
Protected Overrides Sub OnCustomCommand(ByVal command As Integer)
是否也可以从 VB6 到 .net Windows 服务执行命令?
In VB.net I can execute Custom commands on Windows-Services :
Desktop:
Const SmartShutdown As Integer = 12
Dim myService As New ServiceController("SampleService")
myService.ExecuteCommand(SmartShutdown)
Windows-Service:
Protected Overrides Sub OnCustomCommand(ByVal command As Integer)
Is it also possible to execute commands from VB6 to .net Windows-Service?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 ControlService API 函数发送任何控制代码。
这确实需要您调用 OpenService 具有适当的访问权限并且您的进程正在所需的级别上运行。
在 Vista+ 上,可以使用普通清单(进程范围)或 COM 提升。
You can use the ControlService API function to send any control codes.
This does require that you've called OpenService with the appropriate access and that your process is running at the required level.
On Vista+, this can be done using the normal manifest (process wide) or COM elevation.
考虑使用 VB6 Shell 函数和 < code>sc.exe 控制Windows服务的命令行工具,eg:
Update
发送自定义命令,eg:
自定义命令应在128-255范围内。
Consider using the VB6 Shell function and the
sc.exe
command line tool to control windows services, e.g:Update
To send a custom command, e.g.:
Custom command should be in the range 128-255.