How to register a service?

Just starting out? Need help? Post your questions and find answers here.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

How to register a service?

Post by Mistrel »

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.
jpd
Enthusiast
Enthusiast
Posts: 167
Joined: Fri May 21, 2004 3:31 pm

Post by jpd »

Hi Mistrel,

same used on Win 9x OS

you find an example in OLD PBOSL used for register a process as service

here the example: PBOSL_WIN9XSERVICE.PB


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Ú[}´^

Ciao
jpd
PB 5.10 Windows 7 x64 SP1
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

or a french tutorial , but language is PureBasic ;)

http://f-lefevre.developpez.com/tutorie ... e-windows/
Please correct my english
http://purebasic.developpez.com/
Post Reply