View Issue Details

IDProjectCategoryView StatusLast Update
0006701JEDI API & WSC LibraryGeneral APIpublic2020-06-26 16:12
ReporterMistralAssigned ToChristianWimmer 
PrioritynormalSeverityblockReproducibilityalways
Status assignedResolutionopen 
Summary0006701: TJclSCManager system error 87 (parameter incorrect) in Delphi 10.4 running on Windows 7 or Windows 2008 server
DescriptionI'm using TJclSCManager to manage Windows services. It works well until update to Delphi 10.4.

If I run my program on an older SysOp (Windows 7 or Windows 2008 server) I get always a system error 87 (parameter incorrect) when TjsclManager.Refresh calls EnumServicesStatus. Running on Windows 10 or latest Windows Servers is all fine.

After some debug I've discovered the cause of this error on a change in SERVICE_TYPE_ALL constant on Delphi unit Winapi.WinSvc:

  SERVICE_TYPE_ALL = (SERVICE_WIN32 or
                                   SERVICE_ADAPTER or
                                   SERVICE_DRIVER or
                                   SERVICE_INTERACTIVE_PROCESS or
                                   SERVICE_USER_SERVICE or
                                   SERVICE_USERSERVICE_INSTANCE or
                                   SERVICE_PKG_SERVICE);

in previous Delphi 10.3 this constant was

  SERVICE_TYPE_ALL = (SERVICE_WIN32 or
                                  SERVICE_ADAPTER or
                                  SERVICE_DRIVER or
                                  SERVICE_INTERACTIVE_PROCESS);


TjsclManager.Refresh calls the EnumServicesStatus api in this way:

        Ret := EnumServicesStatus(FHandle, SERVICE_TYPE_ALL , SERVICE_STATE_ALL,
          PEnumServiceStatus(PBuf){$IFNDEF FPC}{$IFNDEF RTL340_UP}^{$ENDIF}{$ENDIF},
          BytesNeeded, BytesNeeded, ServicesReturned, ResumeHandle);

 this causes the problem in older sysop because as you can see here:

https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-enumservicesstatusexa

EnumServicesStatus allows only a few of the declared constants for the dwServiceType parameter.

I solved changing JclSvcCtrl unit in this way:

        Ret := EnumServicesStatus(FHandle, SERVICE_WIN32 or
                                   SERVICE_ADAPTER or
                                   SERVICE_DRIVER or
                                   SERVICE_INTERACTIVE_PROCESS, SERVICE_STATE_ALL,
          PEnumServiceStatus(PBuf){$IFNDEF FPC}{$IFNDEF RTL340_UP}^{$ENDIF}{$ENDIF},
          BytesNeeded, BytesNeeded, ServicesReturned, ResumeHandle);



TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2020-06-26 16:12 Mistral New Issue
2020-06-26 16:12 Mistral Status new => assigned
2020-06-26 16:12 Mistral Assigned To => ChristianWimmer