I would like to submit some information collected from user during Inno setup installation to our server via POST.
Obvious solution would be to include an .exe file that the setup would extract into temporary location and launch with parameters. However, I’m wondering – is there is any easier/better way?
Based on jsobo advice of using WinHTTP library, I came with this very simple code that does the trick. Say, you want to send serial number for verification just before the actual installation starts. In the
Codesection, put:The
Openmethod takes as arguments the HTTP method, the URL and whether to do async request and it seems like we need to addSetRequestHeaderin order to set theContent-Typeheader toapplication/x-www-form-urlencoded.WinHttpReq.Statuswill hold the response code, so to check if the server returned successfully:https://learn.microsoft.com/en-us/windows/win32/winhttp/winhttprequest lists all methods and properties of the
WinHttpRequestobject.Also, to avoid run-time errors (can happen if the host is unreachable) it is a good idea to surround the code with
try/exceptcode.