How I could ignore the error msgbox if the uninstall.vsf file does not exists when calling LoadVCLStyle_UnInstall function in this code?
I supposed that using a Try block with an empty Except will be enough as in other languages, but this is not the case.
// Import the LoadVCLStyle function from VclStylesInno.DLL
procedure LoadVCLStyle_UnInstall(VClStyleFile: String); external 'LoadVCLStyleA@{app}\uninstall.dll stdcall uninstallonly';
//E: Occurs when the uninstaller initializes.
function InitializeUninstall: Boolean;
begin
Result := True;
// Initialize the VCL skin style.
try
LoadVCLStyle_UnInstall(ExpandConstant('{app}\uninstall.vsf'));
except
finally
end;
end;

The possibility to check for the file existence beforehand was already mentioned.
The user TLama mentioned that the code in the question is not regular pascal program code, but Inno Setup script code and and that my answer doesn't apply in this case. Because the following text could be of interest for pascal programmers we keep it.
The
EXCEPTstatement by itself doesn't handle the exception, it marks only the point where program execution should continue after an error has occured. When the exception isn't handled/caught in theEXCEPT ... ENDblock it will be transferd to the next higherEXCEPTstatement. (Freepacal reference guide chapter 17)I also don't think that
TRY ... EXCEPT ... FINALLY ... ENDwill work. EitherEXCEPTorFINALLY, not both.If you want to capture the exception you must do something like:
If the exception class for this error isn't defined in the documentation, you can use the following trick to find the exception class name:
With
ON Exception DO ..you can catch any exception, but i don't recomend to use that variant for the definite program.