CreateService_ fails in PB 6.12

Just starting out? Need help? Post your questions and find answers here.
swhite
Addict
Addict
Posts: 805
Joined: Thu May 21, 2009 6:56 pm

CreateService_ fails in PB 6.12

Post 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
Simon White
dCipher Computing
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: CreateService_ fails in PB 6.12

Post 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.
User avatar
Bisonte
Addict
Addict
Posts: 1320
Joined: Tue Oct 09, 2007 2:15 am

Re: CreateService_ fails in PB 6.12

Post by Bisonte »

Handles have to be ALWAYS Integer... :!:
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
swhite
Addict
Addict
Posts: 805
Joined: Thu May 21, 2009 6:56 pm

Re: CreateService_ fails in PB 6.12

Post by swhite »

Thank-you changing the longs to integer solved the problem.

Simon
Simon White
dCipher Computing
Post Reply