You might wanna read the help files for INNO setup. If there is a buildin function which can return it, it will be listed in the help files/pages.
------
The ShellExecute() and ShellExecuteEx() Windows APIs do not return a process' exit code! Neither ShellExecute(), nor ShellExecuteEx() can help you with this. Those APIs can't be used for this.
If you want to use a Windows API to do that you need to use the Windows API
GetProcessExitCode().
For this you need to get a process handle which can be used as a parameter for GetProcessExitCode(). To get this process handle you must use the Windows API
OpenProcess or
CreateProcess or the likes.
For more detailed help and how exactly all those APIs are used, see the
MSDN Library