![Utils Library Delphi C++ Builder | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/Utils-Library-Delphi-C-Builder.png?resize=1140%2C675&ssl=1)
Table of Contents
Intro
When you start building any project, you might end up creating functions to use in several points of your application. Maybe you develop a set of code snippets. Utilities are an important point of connection between your software and the device it runs on, but what if you didn’t have to create them yourself?
WinSoft offers a Utils library that gives you a bunch of functions to accomplish more things. For example, audio managing, ringtone managing, working with sensor or vibrator for Android, getting operating system, IP, mac, memory, system timing details. There is more! Moreover, there are also utility libraries for macOS and iOS too.
Specifications
- Supported OSs: Win32-64, Android32-64, macOS 64 & iOS 64
- Available for Delphi & C++ Builder 6-10.4
Configuration
Here is an installation video tutorial of configuring for Windows OS, macOS, iOS, and Android.
Here’s a quick demo of the code in Utils as well:
Development
Let’s start investigating essential VCL features of this Utils library.
Fetching IP Address
First, you should add the required unit, which is the Utils module here.
1 2 3 4 5 |
program IpAddress; uses Utils, XPMan; begin ShowInfo('Host: ' + HostName + NewLine + 'IP Address: ' + Utils.IpAddress(HostName), 'IP Address'); end. |
Getting MAC Address
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
program MacAddress; uses Types, SysUtils, Utils, XPMan; var Text: string; Addresses: TMacAddresses; Address: TByteDynArray; begin Text := ''; SetLength(Address, Sizeof(TMacAddress)); Addresses := MacAddresses; for var I: Integer := 0 to Length(Addresses) - 1 do begin Move(Addresses[I], Address[0], SizeOf(TMacAddress)); Text := Catenate(Text, 'Adapter ' + IntToStr(I + 1) + ': ' + ToHex(Address, '-'), NewLine); end; ShowInfo(Text, 'MAC Address'); end. |
Fetching Memory Status
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
program MemoryStatus; uses SysUtils, Utils, XPMan; const MB = 1024 * 1024; var Text: string; InUse: Integer; PhysicalTotal, PhysicalFree: UInt64; VirtualTotal, VirtualFree: UInt64; PagingTotal, PagingFree: UInt64; begin if Utils.MemoryStatus(InUse, PhysicalTotal, PhysicalFree, VirtualTotal, VirtualFree, PagingTotal, PagingFree) then begin Text := 'Memory in use: ' + IntToStr(InUse) + '%' + NewLine + NewLine + 'Total physical memory: ' + IntToStr(PhysicalTotal div MB) + ' MB' + NewLine + 'Free physical memory: ' + IntToStr(PhysicalFree div MB) + ' MB' + NewLine + NewLine + 'Total virtual memory: ' + IntToStr(VirtualTotal div MB) + ' MB' + NewLine + 'Free virtual memory: ' + IntToStr(VirtualFree div MB) + ' MB' + NewLine + NewLine + 'Total paging file: ' + IntToStr(PagingTotal div MB) + ' MB' + NewLine + 'Free paging file: ' + IntToStr(PagingFree div MB) + ' MB'; ShowInfo(Text, 'Memory Status'); end else ShowError('Cannot retrieve memory status', 'Memory Status'); end. |
Result:
![utils library for delphi and C++ Builder memory status example | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/utils-library-for-delphi-and-C-Builder-memory-status-example.png?resize=249%2C234&ssl=1)
Turning On and Off Monitor
1 2 3 4 5 6 7 8 |
program MonitorOff; uses Utils, XPMan; begin if ShowQuestion('Turn Off Monitor?', 'Monitor Off') then Utils.MonitorOff; end. |
There are more functionalities that you can utilize, just explore the Utils module!
In the next post, we look through the Android OS utilities:
- Ringtone
- Sensors
- Text to Speech
- Vibrator
Head over and check out the full WINSOFT Utils Library for Delphi and C++ Builder
Like what you see? You can get the Utils Library and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4 today!
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition