Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
FormatApplicationUserModelId

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_      PCWSTR packageFamilyName,
  _In_      PCWSTR packageRelativeApplicationId,
  _Inout_   UINT32 *applicationUserModelIdLength,
  _Out_opt_ PWSTR  applicationUserModelId
);

Parameters

packageFamilyName [in]

Type: PCWSTR

The package family name.

packageRelativeApplicationId [in]

Type: PCWSTR

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_reads_(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 rc;
    }
    else if (rc != ERROR_INSUFFICIENT_BUFFER)
    {
        wprintf(L"Error %d in FormatApplicationUserModelId \n", rc);
        return rc;
    }

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

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

    free(applicationUserModelId);

    return 0;
}


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:
© 2015 Microsoft