Accessing internet resources becomes a common feature in modern desktop windows applications. Thinking how to build these capabilities in your Delphi/C++ FireMonkey Applications? WINSOFT made a Flexible component suite that helps you to access internet resources with FTP, and HTTP/HTTPS protocols. It uses the Standard Microsoft WinInet API.
Features:
- It supports FTP, HTTP, and HTTPS protocols.
- Well suited for accessing REST Services.
- Flexibility to set AutoDial options for Modem dial and hang-up internet connection.
- The session access type is configurable.
- Able to navigate and manipulate directories and files on an FTP server.
- Caching of files for FTP resources can be controlled.
- Built with action for Error handling mechanism.
- Able to set and get cookies from a persistent cookie database.
Versions Supported: Delphi/C++Builder XE2 – 10.4
Platforms: Windows, OS X, iOS and Android;
Installation Steps:
Prerequisites: Ensure 5.8 MB minimum free space available in the system.
- Download FWinNet Setup and Right-click Open.
- Read the Information Window about features, installation, and copyright. Click Next.
- Browse for the custom destination folder to install and click Next.
- Browse for the custom Start Menu folder and click Next. You can ignore creating by clicking the checkbox Don’t create a Start Menu folder option.
- Review your folder settings and click Install. You can click Back to change your folder settings.
- Once Installation Progress is done click Finish.
- Ensure the WinInet Component Suite For FireMonkey files are shown in the chosen Start Menu Folder by clicking Windows Start Menu.
Installation Steps Demo:
How to build your application with WinInet Components:
1.Open RAD Studio 10.4, Navigate to Components bar -> Internet. Check the WinInetSuite Components installed as shown.
TFINetConnection: Connected property is true when connected to the internet and State property shows the corresponding connected state. This component enables you to dial and hangup modem with options provided retrieves the connected state. It has methods to AttempConnect, CheckConnection, Connect, Dial, Hang-up. Enabling Internet functionality.
TFINetURL: It encapsulates WinInet Uniform Resource Locator functions. Use this component, for manipulation of URLs. It has properties like CanonizedURL, HostName, Port, Username, Password, URL, URLPath, Scheme. Handling Uniform Resource Locator.
TFINetSession: Enables you to set Internet Initialization parameters. It encapsulates Internet handle returned by InternetOpen WinInet function.
- Active: Open or close a session.
- Agent: Specifies the name of the application, used as user agent in HTTP or FTP protocol.
- Flags: Internet Flags, Offline or Async.
- ProxyByPass: List of IP address shat should not be routed through the proxy.
- ProxyName: Name of the proxy server.
- SetInternetOption : Use this method to set internet options like cache control, content decoding. Options Flags
- There are session events to perform operations BeforeOpen,AfterOpen,BeforeClose,AfterClose. OnCallBack Occurs when progress is made during an internet operation.
- OnError Event TFINetAction parameter helps to abort the application and display or without displaying an error message.
TFINetHttp : Access Resources on the World Wide Web using HTTP Protocol.
- Use Active to open or closes the connection.
- Use the Flags Property to Set HTTPFlags. Use HttpHandle property for HTTP requests.
- Customize the Request using the SecurityFlags for Http Request.
- Predefined Session will be used if the Session property is empty.
- URL, URLPath, UserName, Password can be preconfigured for the request. Use Verb property to use in the request.
- Use QueryInfo to retrieve header information associated with HTTP requests.
2. Drag and Drop TFINetHttp component or alternatively use FWINet.pas file to include.
3.A simple Code snippet to access the Internet resource using the TFINetHttp component.
1 2 3 4 5 6 7 8 9 10 |
with FINetHttp do try Url := EditUrl.Text; Open; OpenRequest; SendRequest; Memo.Lines.Text := string(ReadData); finally Close; end; |
TFINetFtp : Component to navigate and manipulate directories and files on a FTP Server.
- Use Active to open or closes the connection.
- Use the CacheFlags Property to control the caching of files.
- Use Handle,FileHandle,FindFileHandle properties returned by InternetConnect,ftpOpenFile,ftpFindFirstFile functions respectively.
- the predefined session will be used if the session property is empty.
- Configure the ftp TransferType.
- Use AvailableData to read the number of bytes returned.
- There are events to perform operations BeforeOpen,AfterOpen,BeforeClose,AfterClose. OnCallBack Occurs when progress is made during an internet operation.
- OnError Event TFINetAction parameter helps to abort the application and display or without displaying an error message.
4. Drag and Drop TFINetFTP component or alternatively use FWINet.pas file to include. Code snippet to Connect with FTP and set the current directory.
1 2 3 4 5 6 7 8 9 10 11 |
try FINetFtp.Close; FINetUrl.Url := EditUrl.Text; FINetFtp.ServerName := FINetUrl.HostName; FINetFtp.Open; if FINetUrl.UrlPath <> '' then FINetFtp.SetCurrentDirectory(FINetUrl.UrlPath); finally if FINetFtp.Active then RefreshFileList; end; |
5. Creates a Directory with the provided name.
1 |
FINetFtp.CreateDirectory(DirectoryName); |
6.Removes the Selected Directory.
1 |
FINetFtp.RemoveDirectory(GetSelectedDirectory); |
7.Puts the File to the current directory.
1 |
FINetFtp.PutFile(FileName, ExtractFileName(FileName)); |
8.Retrieves a file from the FTP server and stores it under the specified file name, creating a new local file.
1 |
FINetFtp.GetFile(GetSelectedFile, FileName, False, []); |
9.Renames a file stored on the FTP server.
1 |
FINetFtp.RenameFile(GetSelectedFile, FileName); |
10.Deletes a file stored on the FTP server.
1 |
FINetFtp.DeleteFile(GetSelectedFile); |
TFINetCookie : SetCookies and retrieve cookies from persistent cookie database. Used to maintain the state. information of the client.
- CookieData: Cookie Data.
- CookieName: Name of the cookie.
- Url: Cookie associated Url.
11. To set cookie,
1 2 3 |
FINetCookie.URL := EditURL.Text; FINetCookie.CookieName := EditName.Text; FINetCookie.CookieData := EditValue.Text; |
12.To get cookie,
1 2 3 |
FINetCookie.URL := EditURL.Text; FINetCookie.CookieName := EditName.Text; EditValue.Text := FINetCookie.CookieData; |
Sample Application Demo:
Conclusion: It’s easy to access internet resources using HTTP and FTP protocols in your applications. WINSOFT helped us to easily configure and use these components to build faster applications.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition