如何调试服务程序

najzni 2005-04-10 05:30:27
如题
...全文
350 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangk 2005-04-11
  • 打赏
  • 举报
回复
启动Debug版Service,用VC Attach到上面,然后用Soft Break,接着在源码里下断点,接着运行就可以了。有些词汉语我不大会解释,如果你用的是英文版,大概会明白吧。
alphapiao 2005-04-11
  • 打赏
  • 举报
回复
用SoftIce可以任何时候打开。也可以实现源代码调试,不过设置比较繁。
但是你可以用SoftIce捕获OutputDebugString()输出,做一些简单调试。
idAnts 2005-04-11
  • 打赏
  • 举报
回复
用OutputDebugString()
masterz 2005-04-10
  • 打赏
  • 举报
回复
MSDN有介绍
Debugging a Service

You can use any one of the following methods to debug your service.

* Use your debugger to debug the service while it is running. First, obtain the process identifier (PID) of the service process. After you have obtained the PID, attach to the running process. For syntax information, see the documentation included with your debugger.
* Call the DebugBreak function to invoke the debugger for just-in-time debugging.
* Specify a debugger to use when starting a program. To do so, create a key called Image File Execution Options in the following registry location:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

Create a subkey with the same name as your service (for example, MYSERV.EXE). To this subkey, add a value of type REG_SZ, named Debugger. Use the full path to the debugger as the string value. In the Services control panel applet, select your service, click Startup and check Allow Service to Interact with Desktop. Note that the service must be an interactive service, or else the debugger cannot run on the default desktop.

To debug the initialization code of an auto-start service, you will have to temporarily install and run the service as a demand-start service.

At times, it may be necessary to run a service as a console application for debugging purposes. In this scenario, the StartServiceCtrlDispatcher function will return ERROR_FAILED_SERVICE_CONTROLLER_CONNECT. Therefore, be sure to structure your code such that service-specific code is not called when this error is returned.
najzni 2005-04-10
  • 打赏
  • 举报
回复
怎么启?好像不得行耶
晨星 2005-04-10
  • 打赏
  • 举报
回复
服务程序不能从Visual Studio里启动么?
najzni 2005-04-10
  • 打赏
  • 举报
回复
一般的程序可以在调试器里单步执行,服务程序怎么调试?
晨星 2005-04-10
  • 打赏
  • 举报
回复
跟客户端联合调试不可以吗?

2,641

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧