


IfThen( LED, 'on', 'off') + '=' + IntToStr(Key_Hardware_ID) procedure TfmHaspList.YieldBlinkHTTP(const LED: boolean const Key_Hardware_ID: cardinal) So while I do issue requests, I do not care about their results, that result is ignored and dumped. Also it would definitely not be the case for async (multithread) work.īelow is the snippet from a real code running. Reportedly it might not be always the case for simplistic apps or for LCL apps. In the code above I imply that COM was already initialized for the main VCL thread. How to use "WinHttp.WinHttpRequest.5.1" asynchronously?.Save a file downloaded via WinHTTP to disk, using Delphi XE.procedure TForm1.Button1Click(Sender: TObject)

Using Windows HTTP API might be easy too. Hope it helps for somebody like me who was looking for easy code how to retrieve page content in Delphi. Raise Exception.CreateFmt('Cannot open URL %s', ) InternetReadFile(UrlHandle, SizeOf(Buffer), BytesRead) NetHandle := InternetOpen('Delphi 2009', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0) uses WinInet įunction GetUrlContent(const Url: string): UTF8String Example returns retrieved data as UTF8String so it will work well for ASCII as well as for UTF8 pages.

So I modified it a little bit so it actually returns String and gracefully closes everything after execution. The WinINet API uses the same stuff InternetExplorer is using so you also get any connection and proxy settings set by InternetExplorer for free.Īctually code in accepted answer did't work for me. Raise Exception.Create('Unable to initialize Wininet') UrlHandle := InternetOpenUrl(NetHandle, PChar(Url), nil, 0, INTERNET_FLAG_RELOAD, 0) NetHandle := InternetOpen('Delphi 5.x', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0) You could use the WinINet API like this: uses WinInet įunction GetUrlContent(const Url: string): string
