Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

FormatApplicationUserModelId function

Constructs an application user model ID from the package family name and the package relative application ID (PRAID).

Syntax


LONG WINAPI FormatApplicationUserModelId(
  _In_       PWSTR packageFamilyName,
  _In_       PWSTR packageRelativeApplicationId,
  _Inout_    UINT32 *applicationUserModelIdLength,
  _Out_opt_  PWSTR applicationUserModelId
);

Parameters

packageFamilyName [in]

Type: PWSTR

The package family name.

packageRelativeApplicationId [in]

Type: PWSTR

The package-relative app ID (PRAID).

applicationUserModelIdLength [in, out]

Type: UINT32*

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

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

applicationUserModelId [out, optional]

Type: PWSTR

A pointer to memory space that receives the app user model ID 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 packageFamilyName or packageRelativeApplicationId parameter isn't valid.

ERROR_INSUFFICIENT_BUFFER

The buffer specified by applicationUserModelId is not large enough to hold the data; the required buffer size, in WCHARs, is stored in the variable pointed to by applicationUserModelIdLength.

 

Examples



#define _UNICODE 1
#define UNICODE 1

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

int ShowUsage()
{
    wprintf(L"Usage: FormatApplicationUserModelId <packagefamilyname> <applicationid>\n");
    return 1;
}

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

    PCWSTR packageFamilyName = argv[1];
    PCWSTR packageRelativeApplicationId = argv[2];
    wprintf(L"PackageFamilyName: %s\n"
            L"PackageRelativeApplicationId: %s\n",
            packageFamilyName,
            packageRelativeApplicationId);

    UINT32 length = 0;
    LONG rc = FormatApplicationUserModelId(packageFamilyName, packageRelativeApplicationId, &length, NULL);
    if (rc == ERROR_SUCCESS)
    {
        wprintf(L" FormatApplicationUserModelId unexpectedly succeeded\n");
        return;
    }
    else if (rc != ERROR_INSUFFICIENT_BUFFER)
    {
        wprintf(L"Error %d in FormatApplicationUserModelId \n", rc);
        return;
    }

    PWSTR applicationUserModelId = (PWSTR) malloc(length * sizeof(WCHAR));
    if (applicationUserModelId == NULL)
    {
        wprintf(L"Error allocating memory\n");
        return;
    }

    rc = FormatApplicationUserModelId(packageFamilyName, packageRelativeApplicationId, &length, applicationUserModelId);
    if (rc != ERROR_SUCCESS)
        wprintf(L"Error %d formatting ApplicationUserModelId\n", rc);
    else
        wprintf(L"ApplicationUserModelId = %s\n", applicationUserModelId);

    free(applicationUserModelId);
}


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

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.