How to register a service?
Posted: Tue Oct 14, 2008 3:50 am
I read online that I can use the API RegisterServiceProcess for this but I can't find it. It's not in Kernel32.dll either.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
; Library: Win9xService
; By Gansta93
; Licenced under LGPL
; Date: 06/11/2005
; Compiled with TailBite 1.2PR1.0 on PureBasic 3.94 under Win 98 SE
; Initialisation procedure
ProcedureDLL Win9xService_Init()
Global Kernel32 ; ID of Kernel32
Global FunctionPointer ; Pointer to the function, to be called with CallFunctionFast()
Kernel32 = OpenLibrary(#PB_Any,"Kernel32.dll")
If Kernel32
FunctionPointer = IsFunction(Kernel32,"RegisterServiceProcess")
EndIf
EndProcedure
; Procedure to register the current process as a service.
ProcedureDLL Win9xService(State) ; Register a process as a service for Win 9x.
If GetVersion_() & $FF0000
ProcedureReturn #False
Else
ProcedureReturn CallFunctionFast(FunctionPointer,GetCurrentProcessId_(),State)
EndIf
EndProcedure
; Debug procedure.
ProcedureCDLL Win9xService_Debug(State)
If FunctionPointer = 0
TB_DebugError("Win9xService Initialisation problem.")
EndIf
EndProcedure
; Register a service, but specify a Pid.
ProcedureDLL Win9xService2(State,Pid) ; Register a process as a service for Win 9x.
If GetVersion_() & $FF0000 ; check of NT
ProcedureReturn #False
Else
ProcedureReturn CallFunctionFast(FunctionPointer,Pid,State)
EndIf
EndProcedure
; Debugging
ProcedureCDLL Win9xService2_Debug(State,Pid)
If FunctionPointer = 0
TB_DebugError("Win9xService Initialisation problem.")
EndIf
EndProcedure
; Procedure called on end.
ProcedureDLL Win9xService_End()
CloseLibrary(Kernel32)
Kernel32 = 0
FunctionPointer = 0
EndProcedure
; End of library.
; IDE Options = PureBasic v3.94 (Windows - x86)
; EnableXP
; CPU = 1
; DisableDebugger
; HideErrorLogÚ[}´^