SYSTEMTIME curr_st; GetLocalTime(&curr_st); int year = curr_st.wYear; int month = curr_st.wMonth; int day = curr_st.wDay; int hour = curr_st.wHour; int minute = curr_st.wMinute; int second = curr_st.wSecond;
用调试器(OD,WINDBG等)调试服务程序 To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key:
The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe.
Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example,
c:\Debuggers\windbg.exe
In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop.
This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example:
Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key:
Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours.
设置ServicesPipeTimeout后需要重启系统才生效
Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.)
If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.
#6
改用命令行注册你的服务:
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own sc description yy8 "this is a service test" sc start yy8
或者做一个批处理文件,如install.bat
内容如下:
@echo off
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own
sc description yy8 "this is a service test"
sc start yy8
或者干脆打开我的电脑的服务管理界面
右键你的服务属性,选择登录,勾选“允许服务与界面交互”
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own sc description yy8 "this is a service test" sc start yy8
或者做一个批处理文件,如install.bat
内容如下:
@echo off
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own
sc description yy8 "this is a service test"
sc start yy8
或者干脆打开我的电脑的服务管理界面
右键你的服务属性,选择登录,勾选“允许服务与界面交互”
用调试器(OD,WINDBG等)调试服务程序 To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key:
The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe.
Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example,
c:\Debuggers\windbg.exe
In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop.
This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example:
Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key:
Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours.
设置ServicesPipeTimeout后需要重启系统才生效
Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.)
If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.
#6
改用命令行注册你的服务:
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own sc description yy8 "this is a service test" sc start yy8
或者做一个批处理文件,如install.bat
内容如下:
@echo off
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own
sc description yy8 "this is a service test"
sc start yy8
或者干脆打开我的电脑的服务管理界面
右键你的服务属性,选择登录,勾选“允许服务与界面交互”
#7
改用命令行注册你的服务:
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own sc description yy8 "this is a service test" sc start yy8
或者做一个批处理文件,如install.bat
内容如下:
@echo off
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own
sc description yy8 "this is a service test"
sc start yy8
或者干脆打开我的电脑的服务管理界面
右键你的服务属性,选择登录,勾选“允许服务与界面交互”
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own sc description yy8 "this is a service test" sc start yy8
或者做一个批处理文件,如install.bat
内容如下:
@echo off
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own
sc description yy8 "this is a service test"
sc start yy8
或者干脆打开我的电脑的服务管理界面
右键你的服务属性,选择登录,勾选“允许服务与界面交互”
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own sc description yy8 "this is a service test" sc start yy8
或者做一个批处理文件,如install.bat
内容如下:
@echo off
sc create yy8 binPath= "D:\yourService.exe" DisplayName= "my service test" start= auto type= interact type= own
sc description yy8 "this is a service test"
sc start yy8
或者干脆打开我的电脑的服务管理界面
右键你的服务属性,选择登录,勾选“允许服务与界面交互”