Page 1 of 1

CreateService_ fails in PB 6.12

Posted: Fri Dec 20, 2024 4:34 pm
by swhite
Hi

I have used the following code for years to create Windows services using PB. However in PB6.12 it fails to create the service. When I re-compile my app in PB 5.73 the code creates the service. I am testing this on Windows 2022 Standard Server.

Code: Select all

Procedure Service_Install(tcService.s)
   Protected lcDir.s, lhSCManager.l, lhService.l, SD.SERVICE_DESCRIPTION
   
   lcDir        = GetCurrentDirectory() + #dCServiceAppName
   lhSCManager  = OpenSCManager_(#Null, #Null, #SC_MANAGER_ALL_ACCESS)
   lhService    = CreateService_(lhSCManager, tcService, #dCServiceDisplayName, #SERVICE_ALL_ACCESS, #SERVICE_WIN32_OWN_PROCESS, #SERVICE_AUTO_START, #SERVICE_ERROR_NORMAL, lcDir, #Null, #Null, #Null, #Null, #Null)
   
   SD\lpDescription = @"Fuelwize eReceipts"
   
   ChangeServiceConfig2_(lhService, #SERVICE_CONFIG_DESCRIPTION, @SD)
   CloseServiceHandle_(lhService)
   CloseServiceHandle_(lhSCManager)
   
EndProcedure

Re: CreateService_ fails in PB 6.12

Posted: Fri Dec 20, 2024 6:25 pm
by Quin
I haven't tested this, but maybe try changing your .l's to .i? This is the most common problem I hear of people having when moving from 5.73 to 6.xx versions, because PB now uses some emory safety feature that makes attacks much harder, but also makes addresses much bigger so they're less likely to fit into 32-bit longs on 64-bit systems.

Re: CreateService_ fails in PB 6.12

Posted: Sat Dec 21, 2024 9:29 am
by Bisonte
Handles have to be ALWAYS Integer... :!:

Re: CreateService_ fails in PB 6.12

Posted: Tue Dec 31, 2024 5:11 pm
by swhite
Thank-you changing the longs to integer solved the problem.

Simon