Skip to content

Latest commit

 

History

History
214 lines (160 loc) · 5.56 KB

nf-appmodel-packagenameandpublisheridfromfamilyname.md

File metadata and controls

214 lines (160 loc) · 5.56 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:appmodel.PackageNameAndPublisherIdFromFamilyName
PackageNameAndPublisherIdFromFamilyName function (appmodel.h)
Gets the package name and publisher identifier (ID) for the specified package family name.
PackageNameAndPublisherIdFromFamilyName
PackageNameAndPublisherIdFromFamilyName function [App packaging and management]
appmodel/PackageNameAndPublisherIdFromFamilyName
appxpkg.packagenameandpublisheridfromfamilyname
appxpkg\packagenameandpublisheridfromfamilyname.htm
appxpkg
4AA5BD75-F865-40D6-9C10-E54C197D47C4
12/05/2018
PackageNameAndPublisherIdFromFamilyName, PackageNameAndPublisherIdFromFamilyName function [App packaging and management], appmodel/PackageNameAndPublisherIdFromFamilyName, appxpkg.packagenameandpublisheridfromfamilyname
appmodel.h
Windows
Windows 8 [desktop apps \| UWP apps]
Windows Server 2012 [desktop apps \| UWP apps]
Kernel32.lib
Kernel32.dll
Windows
19H1
PackageNameAndPublisherIdFromFamilyName
appmodel/PackageNameAndPublisherIdFromFamilyName
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-AppModel-Runtime-l1-1-0.dll
kernel32legacy.dll
Kernel.AppCore.dll
API-MS-Win-AppModel-RunTime-l1-1-1.dll
API-MS-Win-AppModel-Runtime-L1-1-2.dll
PackageNameAndPublisherIdFromFamilyName

PackageNameAndPublisherIdFromFamilyName function

-description

Gets the package name and publisher identifier (ID) for the specified package family name.

-parameters

-param packageFamilyName [in]

Type: PCWSTR

The family name of a package.

-param packageNameLength [in, out]

Type: UINT32*

On input, the size of the packageName buffer, in characters. On output, the size of the package name returned, in characters, including the null-terminator.

-param packageName [out, optional]

Type: PWSTR

The package name.

-param packagePublisherIdLength [in, out]

Type: UINT32*

On input, the size of the packagePublishId buffer, in characters. On output, the size of the publisher ID returned, in characters, including the null-terminator.

-param packagePublisherId [out, optional]

Type: PWSTR

The package publisher ID.

-returns

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 code Description
ERROR_INSUFFICIENT_BUFFER
One of the buffers is not large enough to hold the data. The required sizes are specified by packageNameLength and packagePublisherIdLength.

-remarks

For info about string size limits, see Identity constants.

Examples

#define _UNICODE 1
#define UNICODE 1

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

int ShowUsage();
void FamilyNameToNameAndPublisherId(__in PCWSTR familyName);

int ShowUsage()
{
    wprintf(L"Usage: PackageNameAndPublisherIdFromFamilyName <familyname> [<familyname>...]\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)
        FamilyNameToNameAndPublisherId(argv[i]);

    return 0;
}

void FamilyNameToNameAndPublisherId(__in PCWSTR familyName)
{
    wprintf(L"FamilyName: %s\n", familyName);
    UINT32 nameLength = 0;
    UINT32 publisherIdLength = 0;
    LONG rc = PackageNameAndPublisherIdFromFamilyName(familyName, &nameLength, NULL, &publisherIdLength, NULL);
    if (rc == ERROR_SUCCESS)
    {
        wprintf(L"PackageNameAndPublisherIdFromFamilyName unexpectedly succeeded\n");
        return;
    }
    else if (rc != ERROR_INSUFFICIENT_BUFFER)
    {
        wprintf(L"Error %d in PackageNameAndPublisherIdFromFamilyName\n", rc);
        return;
    }

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

    PWSTR publisherId = (PWSTR) malloc(publisherIdLength * sizeof(WCHAR));
    if (publisherId == NULL)
    {
        wprintf(L"Error allocating memory\n");
        free(name);
        return;
    }

    rc = PackageNameAndPublisherIdFromFamilyName(familyName, &nameLength, name, &publisherIdLength, publisherId);
    if (rc != ERROR_SUCCESS)
        wprintf(L"Error %d converting PackageFamilyName to Name and PublisherId\n", rc);
    else
    {
        wprintf(L"        Name = %s\n", name);
        wprintf(L"Publisher Id = %s\n", publisherId);
    }

    free(name);
    free(publisherId);
}

-see-also

PackageFamilyNameFromFullName

PackageFamilyNameFromId

PackageFullNameFromId

PackageIdFromFullName