Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Enable Windows Portable Devices (WPD) feature in your Delphi and C++ Builder Projects!

Overview

The Windows Portable Devices (WPD) feature allows computers to communicate with the attached media and storage devices. With the WPD, you can explore a device, for instance, smartphones, flash USB cards, and many more.

If you want to enable the WPD feature in your Delphi and C++ Builder Windows application, you can utilize the Portable library by WINSOFT to connect WPD Application Programming Interfaces.

This is a commercial library that has a trial version with all features for evaluation only. If you wish to distribute the Portable library as a part of your project, you should get a license.

Intro

The Portable library by WINSOFT can be used for exploring devices, to send and receive content, and also to command devices. The library also supports Media Transport Protocol (MTP) and Mass Storage Class (MSC) devices.

Specifications

Configuration and Use

You can follow this installation video that shows how to configure your RAD Studio with this library.

You can also see the Portable library in action here:

Development

User Interface

Sometimes a user interface looks simple, but behind that, we have many processes going on—for instance, this demo. With the Combobox, you can select available devices, and with the TreeView, you can open folders and explore contents in that portable device.

Also, the Download, Upload and Delete buttons works as it is, Download downloads the file opens a dialog box to save it, Upload, uploads a file, and Delete, deletes selected file or data from a chosen portable device.

To use this Portable library, you should declare the Portable unit in your uses list. And you need several object instances to control devices, for example, TDeviceManager for getting available portable devices and TDeviceContent for showing the folders and files.

Let’s explore the OnCreate event now: 

[crayon-674244ec0b54a713948212/]

As you can see here we are getting the available portable devices using the DeviceManager instance.

Also, we have the AddChildren function, which helps to get available content from the selected portable device. With the TreeView component, we can display the contents with the right style, in this case, by showing parent and child style.

TTreeView in Action

How are we getting the selected file from the portable device? We need TDeviceObject and TFileStream. If there is a selected object within the Device Object, it opens the save dialog, and then with TDeviceContent, we can start reading the data.

[crayon-674244ec0b553724173655/]

As you have guessed, uploading a file is like Content.Write

And deleting it can be done by Content.Delete function.


Be sure to investigate other features of the Portable library by WINSOFT, and see what else you can accomplish!

Like what you see? You can get the Portable 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!

Exit mobile version