With TLama pointing to the progress bar messages
I was able to solve the problem.
At first I needed to pass the progress bar handle from Inno to my C# app. For this I created a function that would return me the int-pointer as a string
function GetProgressHandle(Param: String): String;
begin
Result := Format('%d',[WizardForm.ProgressGauge.Handle]);
end;
and use it in the Run-section when calling my app:
[Run]
Filename: "{app}\myApp.exe"; Parameters: "{code:GetProgressHandle}"; ....
In C# I read the int-pointer from the console arguments and use it to create an IntPtr
:
IntPtr pointer = new IntPtr(Int32.Parse(args[0]));
To send the messages to the progress bar I imported user32.dll and re-defined the needed constants, that normally can be found in commctrl.h:
[DllImport("user32.dll")]
public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public const uint PBM_SETRANGE = 0x401;
public const uint PBM_SETPOS = 0x402;
Finally, I could set the range of the progress bar from 0 to max and a specific position pos with
PostMessage(pointer, PBM_SETRANGE, (IntPtr)0, (IntPtr)(max << 16));
PostMessage(pointer, PBM_SETPOS, (IntPtr)pos, (IntPtr)0);
NOTE: Changing the progress bar position didn't seem to update the Inno Setup Window immediately. I tested it by increasing the position every 500 ms but there where noticeable differences (pauses were more in the range of ca. 0.2-0.8 ms). For my case it is not important that changing the progress bar is accurately timed, but I assume that the Inno Setup window can be updated in a similar way (with the specific handle and a different message-constant) for those who need this.