Using the WindowsStore Component

TWindowsStore component allows you to connect a Windows application with the Windows Store and use features such as getting a list of apps owned by the user, available add-ons, purchased add-ons, and handle trial mode.

The TWindowsStore component is supported for Windows platforms only and RAD Studio 10.3 Rio includes a VCL version and a FireMonkey version.
TWindowsStore is a component wrapper for the TWindowsStoreCore.

Contents

Checking apps and add-ons owned by the user

To retrieve a list of Windows applications and add-ons owned by the user, you have to insert the TWindowsStore component in the form or create it at runtime, add a TButton, and include the following code:

procedureTStoreForm.lbInfoClick(Sender:TObject);varLMsg:string;const//These consts mirrors the name of the Add-Ons ad defined//in the MS Windows Store. Using this approach you can “Ask” to the//store what the current user has bought.//The current user is indentified automatically because the//app has been downloaded from the store.HENRYFORDQUOTES='henryfordquotes';SAVETOFILE='savetofile';SAVEASFAVOURITE='saveasfavourite';beginLMsg:='**You current situation**'+sLineBreak;LMsg:=LMsg+'You '+IfThen(WindowsStore1.UserHasBought(HENRYFORDQUOTES),'have bought','don''t have bought')+' the great Henry Ford aphorisms archive.'+sLineBreak;LMsg:=LMsg+'You '+IfThen(WindowsStore1.UserHasBought(SAVETOFILE),'have bought','don''t have bought')+' the ability to save aphorisms to file.'+sLineBreak;LMsg:=LMsg+'You '+IfThen(WindowsStore1.UserHasBought(SAVEASFAVOURITE),'have bought','don''t have bought')+' the ability to save aphorisms as favourite.'+sLineBreak;ShowMessage(LMsg);end;

Accessing the available add-ons

The component also allows you to inspect all the available add-ons by accessing the AppProducts indexed property (sgAvailableProducts is a TStringGrid), as in the code shown below:

Checking add-ons owned by the user

To retrieve a list of the add-ons owned by the user, use the UserCollection indexed property, which works in the same way as the AppProducts.

Handling Trial Mode

Use the AppLicense property to handle the TrialMode for your app as shown below:

procedureTStoreForm.lbTrialInformationClick(Sender:TObject);varLRemainingTrialDays:Integer;beginifWindowsStore1.AppLicense.IsActivethenbeginifWindowsStore1.AppLicense.IsTrialthenbeginLRemainingTrialDays:=WindowsStore1.AppLicense.TrialTimeRemaining.Days;ShowMessage(Format('You can use this app for %d more days before the trial period ends.',[LRemainingTrialDays]));endelsebeginShowMessage('You have a full license. The trial time is not meaningful.');end;endelsebeginShowMessage('You don''t have a license. The trial time can''t be determined.');end;End;