TWinWrap:Delphi Wrapper for WinInet
Nearly every computer on the planet that runs Microsoft Windows has Microsoft Internet Explorer installed by default. This also means that WinInet.DLL - Microsoft's API for communicating on the Internet using a range of protocols such as HTTP, HTTPS etc - is available on most computers. This makes it very easy to leverage Internet access functionality into a Delphi application by simply using WinInet. Very easy - provided you understand the intricacies of the WinInet API. Enter TWinWrap, a simple wrapper for WinInet. TWinWrap makes it easy to use the HTTP and HTTPS protocols to launch GET and POST requests without having to understand WinInet. The principal properties of TWinWrap are listed below:
- Content: String - The nature of the data returned by the last successful WinInet call. For instance, the calls in the demo application in the download at the bottom of this page always returns Content:text/html.
- Response: TMemoryStream - The data returned by the last successful GET or POST operation using WinInet is stored here.
TWinWrap exposes two events
- OnCallBack is triggered as a WinInet transaction progresses. It can be used to provide feedback the user.
- OnSized is triggered while a server response is being received. Use it to provide the user with feedback when the server response is slow or lengthy - e.g. when downloading a large file.
The principal methods of TWideStrings are listed below
- constructor CreateEx - This is the object constructor. Internally, it creates an instance of TMemoryStream used to store server responses.
- function Execute( var AInfo: TWinWrapInfo ) :Boolean - Executes a GET, POST or multipart POST request according to the information provided in AInfo. See the sourcecode for examples of how this works.
- procedure CleanUp - Call this method after calling Execute to release resources allocated during the WinInet call.
- procedure UseThisPort( APort: Integer ) - If you want the HTTP(S) request to be made to a port other than the well known ports (80 for HTTP and 443 for HTTPS).