How to get Inno Setup to check if a file doesn't exist
inno-setup, pascalscript
Solution
From the Inno Setup documentation:
All BeforeInstall and AfterInstall functions must not have a return value.
In other words, it can't be a `function`, because it can't return anything; it's a `procedure` instead. (You can see from the examples in the linked page that they're all declared as `procedure`, and none of them contains a `Result` in the code.)
(The question you linked is also wrong, BTW. It shows a `procedure` that has a return type of `Boolean`, which of course isn't possible. I'm suspecting that if it worked it's because the Pascal parser used didn't notice the return value because of the `procedure` in the declaration.)
It appears you're trying to do it wrong, anyway. If `msstdfmt.dll` is being distributed with your `setup`, you should be adding it to the `[Files]` section with the `onlyifdoesntexist` and `regserver` flags set. If it's already installed on the user's system, it should already be registered.
[Files]
Source: "msstdfmt.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist regserver
Problem
When I compile the Inno Setup script below, it gives me an error (below). I borrowed the code from here so I'm not sure why it's not working properly. ``` Line 136: Column 10: Invalid prototype for 'FileDoesNotExist' ``` Line 136 is the `function FileDoesNotExist(file: string): Boolean;` ``` [Run] Filename: "{sys}\regsvr32.exe"; Parameters: "msstdfmt.dll"; WorkingDir: {app}\Pronto\Programs\; BeforeInstall: FileDoesNotExist(ExpandConstant('{sys}\msstdfmt.dll')); StatusMsg: "Registering Controls..." [Code] function FileDoesNotExist(file: string): Boolean; begin if (FileExists(file)) then begin Result := False; end else begin Result := True; end; end; ```