Share via


Funzione PackageNameAndPublisherIdFromFamilyName (appmodel.h)

Ottiene il nome del pacchetto e l'identificatore di autore (ID) per il nome della famiglia di pacchetti specificato.

Sintassi

LONG PackageNameAndPublisherIdFromFamilyName(
  [in]            PCWSTR packageFamilyName,
  [in, out]       UINT32 *packageNameLength,
  [out, optional] PWSTR  packageName,
  [in, out]       UINT32 *packagePublisherIdLength,
  [out, optional] PWSTR  packagePublisherId
);

Parametri

[in] packageFamilyName

Tipo: PCWSTR

Nome della famiglia di un pacchetto.

[in, out] packageNameLength

Tipo: UINT32*

In input, le dimensioni del buffer packageName , in caratteri. Nell'output, le dimensioni del nome del pacchetto restituite, in caratteri, incluso il carattere di terminazione Null.

[out, optional] packageName

Tipo: PWSTR

Nome del pacchetto.

[in, out] packagePublisherIdLength

Tipo: UINT32*

In input, le dimensioni del buffer packagePublishId , in caratteri. Nell'output, le dimensioni dell'ID editore restituite, in caratteri, incluso il carattere di terminazione Null.

[out, optional] packagePublisherId

Tipo: PWSTR

ID editore del pacchetto.

Valore restituito

Tipo: LONG

Se la funzione ha esito positivo, restituisce ERROR_SUCCESS. In caso contrario, la funzione restituisce un codice di errore. I codici di errore possibili includono quanto segue.

Codice restituito Descrizione
ERROR_INSUFFICIENT_BUFFER
Uno dei buffer non è sufficientemente grande da contenere i dati. Le dimensioni necessarie vengono specificate da packageNameLength e packagePublisherIdLength.

Commenti

Per informazioni sui limiti delle dimensioni delle stringhe, vedi Costanti Identity.

Esempio

#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);
}

Requisiti

Requisito Valore
Client minimo supportato Windows 8 [app desktop | App UWP]
Server minimo supportato Windows Server 2012 [app desktop | App UWP]
Piattaforma di destinazione Windows
Intestazione appmodel.h
Libreria Kernel32.lib
DLL Kernel32.dll

Vedere anche

PackageFamilyNameFromFullName

PackageFamilyNameFromId

PackageFullNameFromId

PackageIdFromFullName