- 1 year ago
A way to detect if a service is being uninstalled
To detect if a service is being uninstalled, you can utilize the CurStepChanged
event in Inno Setup. The following example demonstrates how to check if a service is being uninstalled during the uninstallation process:
pascal[Code]
const
SERVICE_NAME = 'YourServiceName';
var
IsServiceBeingUninstalled: Boolean;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssUninstall then
begin
// Check if the service is being uninstalled
IsServiceBeingUninstalled := IsServiceInstalled(SERVICE_NAME);
end;
end;
In the above code, the CurStepChanged
event is triggered when the installation step changes. When the current step is set to ssUninstall
, it means the uninstallation process is in progress. Inside the ssUninstall
block, you can call the IsServiceInstalled
function passing the service name (SERVICE_NAME
) to determine if the service is installed. The result is stored in the IsServiceBeingUninstalled
variable.
Make sure to replace 'YourServiceName'
with the actual name of the service you want to check.
By utilizing this approach, you can detect if a service is being uninstalled and perform any necessary actions based on that information within your Inno Setup script.