VB程序调试不成功

来源:百度知道 编辑:UC知道 时间:2024/05/09 12:00:11
程序代码是书上的
Const RSP_SIMPLE_SERVICE=1
Const RSP_UNREGISTER_SERVICE=0
Private Declare Function GetCurrentProcessId Lib "kernel32"() As Long
Private Declare Function RegisterServiceProcess Lib "kernel32"(byval dwProcessID As Long,byval dwType As Long)As Long

public sub MakeMeService()
dim pid as long,regserv as long
'获取当前进程ID
pid=getcurrentprocessid()
'注册为系统服务
regserv=registerserviceprocess(pid ,RSP_SIMPLE_SERVICE)
end sub

public sub UnMakeMeService()
dim pid as long,regserv as long
'获取当前进程ID
pid=getcurrentprocessid()
'注销为系统服务
regserv=registerserviceprocess(pid ,RSP_UNREGISTER_SERVICE)
end sub

private sub form_load()
MakeMeService
end sub

private sub form_unload(cancle as integer)
UnMakeMeService
end sub
你说的没用

form_load 以前的要放在另外一个module 里面

registerserviceprocess(pid ,RSP_SIMPLE_SERVICE)
上面那句错了~~应该是:
registerserviceprocess(RSP_SIMPLE_SERVICE),pid
'pid的值可能会错误!不是有效的API函数~