Skip to content

Code cleanup at procedure TDaemonThread.HandleControlCode

procedure TDaemonThread.HandleControlCode has the following code:

procedure TDaemonThread.HandleControlCode(ACode, AEventType : DWord; AEventData : Pointer);

Var
  CS : TCurrentStatus;
  CC,OK : Boolean;
  S : String;

begin
 {$ifdef svcdebug}DebugLog('Handling control code '+IntToStr(ACode));{$endif svcdebug}
  CS:=FDaemon.Status;
  Try
    OK:=True;
    CC:=False;
    Case ACode of
      SERVICE_CONTROL_STOP        : OK:=StopDaemon;
      SERVICE_CONTROL_PAUSE       : OK:=PauseDaemon;
      SERVICE_CONTROL_CONTINUE    : OK:=ContinueDaemon;
      SERVICE_CONTROL_SHUTDOWN    : OK:=ShutDownDaemon;
      SERVICE_CONTROL_INTERROGATE : OK:=InterrogateDaemon;
    else
      CC:=True;
      FDaemon.HandleCustomCode(ACode, AEventType, AEventData);
    end;
    If not OK then
      FDaemon.Status:=CS;
  Except
    On E : Exception do
      begin
      // Shutdown MUST be done, in all other cases roll back status.
      If (ACode<>SERVICE_CONTROL_SHUTDOWN) then
        FDaemon.Status:=CS;
      If (ACode in [1..5]) then
        S:=SStatus[ACode]
      else
        S:=Format(SCustomCode,[ACode]);
      end;
  end;
end;

Variables CC and S are declared, have values assigned but they are never used. The following patch removes these two variables from the procedure.

patch.diff

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information