Share via


Switch between handheld profiles programmatically

7/17/2014

This topic shows application developers how to switch between two profiles programmatically on a Windows Embedded 8.1 Handheld device.

Assigned Access

Assigned Access is a core feature of Windows Embedded 8.1 Handheld that enables OEMs to develop lockdown and custom layout experiences on Handheld devices — for example, start screen, settings, apps, and button layouts. Assigned Access is supported by the following additional lockdown features:

For more information on configuring Handheld 8.1, refer to the following:

A common use for Assigned Access is to configure the device to provide access only to a specific list of applications and settings. IT professionals define an allow list, which specifies which applications and settings are available to which users of the device. It is often necessary to support switching user profiles programmatically. This process is outlined below.

Switch between Handheld profiles programmatically

Developers use the Windows.Embedded.DeviceLockdown namespace and its associated classes to support lockdown and profile switching scenarios.

Add capabilities to the app package manifest file as required. For example, if you are going to add the lockdown feature to your sample application, add the ID_CAP_ENTERPRISE_SHARED_DATA capability.

At this time, the Visual Studio 2013 designer does not provide a checkbox for including these capabilities in the app package manifest. You must manually include capabilities in your manifest file. If your application is a Silverlight application (XAP), see this link for how to update the manifest. If your application is a Windows Runtime App (APPX), then add a XML file named "WindowsPhoneReservedAppInfo.xml" to the VS Project with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<WindowsPhoneReservedAppInfo xmlns="https://schemas.microsoft.com/phone/2013/windowsphonereservedappinfo">
  <SoftwareCapabilities>
    <SoftwareCapability Id=" ID_CAP_ENTERPRISE_SHARED_DATA " />
  </SoftwareCapabilities>
</WindowsPhoneReservedAppInfo>

The key APIs used to enumerate, retrieve, and apply profiles are summarized below:

  • Use the DeviceLockdownProfile.GetCurrentLockdownProfile method to retrieve the GUID of the profile currently logged into the Handheld device:

    Guid aProfileID  = DeviceLockdownProfile.GetCurrentLockdownProfile()
    
  • Use the DeviceLockdownProfile.GetLockdownProfileInformation method to retrieve the name and other information about a profile, given its GUID:

    DeviceLockdownProfileInformation aProfile = 
       DeviceLockdownProfile.GetLockdownProfileInformation(aProfileID); // aProfileID is the guid of the role
    
  • Use the DeviceLockdownProfile.GetSupportedLockdownProfiles method to enumerate the available roles on a Handheld device:

    foreach (Guid aProfileID in DeviceLockdownProfile.GetSupportedLockdownProfiles())
    {
       DeviceLockdownProfileInformation aProfile = DeviceLockdownProfile.GetLockdownProfileInformation(aProfileID);
       if (aProfile.Name == "TestProfile")
       {
          Console.Writeline(aProfile.Name); // Do something with the target profile
       }
    }
    
  • Use the DeviceLockdownProfile.ApplyLockdownProfileAsync method to log into a role:

    await DeviceLockdownProfile.ApplyLockdownProfileAsync(guidRole); // guidRole is the Guid associated with the Role
    

See Also

Concepts

Develop Applications (Handheld 8.1)