我有一个更大的Inno安装脚本。
我认为它应该可以正常工作,但由于某些原因它不会。编译器在行function PrepareToInstall
编译器告诉我:
语法错误。
有人发现我的错误吗? 非常感谢你!
[Code]
//I have removed some functions of which I think they don't contribute to the problem
function IsServiceRunning(ServiceName: string): boolean;
var
hSCM: HANDLE;
hService: HANDLE;
Status: SERVICE_STATUS;
begin
hSCM := OpenServiceManager();
Result := false;
if hSCM <> 0 then
begin
hService := OpenService(hSCM, ServiceName, SERVICE_QUERY_STATUS);
if hService <> 0 then
begin
if QueryServiceStatus(hService, Status) then
begin
Result := (Status.dwCurrentState = SERVICE_RUNNING)
end;
CloseServiceHandle(hService)
end;
CloseServiceHandle(hSCM)
end
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
if IsServiceRunning("oscmaintenanceserver") then begin
if StopService("oscmaintenanceserver") then begin
RemoveService("oscmaintenanceserver");
end;
end;
end;
end;
答案 0 :(得分:1)
这是"oscmaintenanceserver"
。 Pascal(脚本)中没有双引号。您始终对string literals使用单引号。
此外,end
中有一个PrepareToInstall
太多。
正确的代码是:
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
if IsServiceRunning('oscmaintenanceserver') then begin
if StopService('oscmaintenanceserver') then begin
RemoveService('oscmaintenanceserver');
end;
end;
end;