PDA

View Full Version : RegisterServiceProcess



sjj
دوشنبه 12 اردیبهشت 1384, 20:03 عصر
سلام دوستان من درباره تابع RegisterServiceProcess یه اشکال دارم
من ازش استفاده کردم ولی error داد که تابع فوق در kernel32.dll پیدا نشد.
می شه منو راهنمایی کنید ؟؟ :گیج:

بابک زواری
دوشنبه 12 اردیبهشت 1384, 20:12 عصر
تعریف تابع


Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long




· dwProcessId
Specifies the identifier of the process to register as a service process. Specifies NULL to register the current process.

· dwType
Specifies whether the service is to be registered or unregistered. This parameter can be one of the following values.
RSP_SIMPLE_SERVICE
Registers the process as a service process.
RSP_UNREGISTER_SERVICE
Unregisters the process as a service pr

یک مثال


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, reserv As Long
'Get the current process ID
pid = GetCurrentProcessId()
'Register as service
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
End Sub
Public Sub UnMakeMeService()
Dim pid As Long, reserv As Long
'Get the current process ID
pid = GetCurrentProcessId()
'Unregister as service
regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)
End Sub
Private Sub Form_Load()
MakeMeService
'Right now, you're program is hidden from the CTRL-ALT-DEL-list
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnMakeMeService
End Sub