Export (0) Print
Expand All

ParseApplicationUserModelId function

Deconstructs an application user model ID to its package family name and package relative application ID (PRAID).

Syntax


LONG WINAPI ParseApplicationUserModelId(
  _In_       PWSTR applicationUserModelId,
  _Inout_    UINT32 *packageFamilyNameLength,
  _Out_opt_  PWSTR packageFamilyName,
  _Inout_    UINT32 *packageRelativeApplicationIdLength,
  _Out_opt_  PWSTR packageRelativeApplicationId
);

Parameters

applicationUserModelId [in]

Type: PWSTR

The app user model ID.

packageFamilyNameLength [in, out]

Type: UINT32*

A pointer to a variable that holds the number of characters (WCHARs) in the package family name string, which includes the null-terminator.

First you pass NULL to packageFamilyName to get the number of characters. You use this number to allocate memory space for packageFamilyName. Then you pass the address of this memory space to fill packageFamilyName.

packageFamilyName [out, optional]

Type: PWSTR

A pointer to memory space that receives the package family name string, which includes the null-terminator.

packageRelativeApplicationIdLength [in, out]

Type: UINT32*

A pointer to a variable that holds the number of characters (WCHARs) in the package-relative app ID string, which includes the null-terminator.

First you pass NULL to packageRelativeApplicationId to get the number of characters. You use this number to allocate memory space for packageRelativeApplicationId. Then you pass the address of this memory space to fill packageRelativeApplicationId.

packageRelativeApplicationId [out, optional]

Type: PWSTR

A pointer to memory space that receives the package-relative app ID (PRAID) string, which includes the null-terminator.

Return value

Type: LONG

If the function succeeds it returns ERROR_SUCCESS. Otherwise, the function returns an error code. The possible error codes include the following.

Return codeDescription
ERROR_INVALID_PARAMETER

The applicationUserModelId parameter isn't valid.

ERROR_INSUFFICIENT_BUFFER

The buffer specified by packageFamilyName or packageRelativeApplicationId is not large enough to hold the data; the required buffer size, in WCHARs, is stored in the variable pointed to by packageFamilyNameLength or packageRelativeApplicationIdLength.

 

Examples



#define _UNICODE 1
#define UNICODE 1

#include <Windows.h>
#include <appmodel.h>
#include <malloc.h>
#include <stdio.h>

int ShowUsage();
void ApplicationUserModelIdToElements(__in PCWSTR applicationUserModelId);

int ShowUsage()
{
    wprintf(L"Usage: ParseApplicationUserModelId <applicationusermodelid> [<applicationusermodelid>...]\n");
    return 1;
}

int __cdecl wmain(__in int argc, __in_ecount(argc) WCHAR * argv[])
{
    if (argc <= 1)
        return ShowUsage();

    for (int i=1; i<argc; ++i)
        ApplicationUserModelIdToElements(argv[i]);

    return 0;
}

void ApplicationUserModelIdToElements(__in PCWSTR applicationUserModelId)
{
    wprintf(L"ApplicationUserModelId: %s\n", applicationUserModelId);
    UINT32 packageFamilyNameLength = 0;
    UINT32 packageRelativeApplicationIdLength = 0;
    LONG rc = ParseApplicationUserModelId(applicationUserModelId, &packageFamilyNameLength, NULL, &packageRelativeApplicationIdLength, NULL);
    if (rc == ERROR_SUCCESS)
    {
        wprintf(L"ParseApplicationUserModelId unexpectedly succeeded\n");
        return;
    }
    else if (rc != ERROR_INSUFFICIENT_BUFFER)
    {
        wprintf(L"Error %d in ParseApplicationUserModelId \n", rc);
        return;
    }

    PWSTR packageFamilyName = (PWSTR) malloc(packageFamilyNameLength * sizeof(WCHAR));
    if (packageFamilyName == NULL)
    {
        wprintf(L"Error allocating memory\n");
        return;
    }
    PWSTR packageRelativeApplicationId = (PWSTR) malloc(packageRelativeApplicationIdLength * sizeof(WCHAR));
    if (packageRelativeApplicationId == NULL)
    {
        wprintf(L"Error allocating memory\n");
        free(packageFamilyName);
        return;
    }

    rc = ParseApplicationUserModelId(applicationUserModelId, &packageFamilyNameLength, packageFamilyName, &packageRelativeApplicationIdLength, packageRelativeApplicationId);
    if (rc != ERROR_SUCCESS)
        wprintf(L"Error %d parsing ApplicationUserModelId\n", rc);
    else
    {
        wprintf(L"Package Family Name = %s\n"                L"Package-Relative Application Id = %s\n",
                packageFamilyName,
                packageRelativeApplicationId);
    }

    free(packageRelativeApplicationId);
    free(packageFamilyName);
}


Requirements

Minimum supported client

Windows 8.1 [desktop apps only]

Minimum supported server

Windows Server 2012 R2 [desktop apps only]

Header

AppModel.h

Library

Kernel32.lib

DLL

Kernel32.dll

 

 

Show:
© 2014 Microsoft