Funzione GetPackageFullName (appmodel.h)

Ottiene il nome completo del pacchetto per il processo specificato.

Sintassi

LONG GetPackageFullName(
  [in]            HANDLE hProcess,
  [in, out]       UINT32 *packageFullNameLength,
  [out, optional] PWSTR  packageFullName
);

Parametri

[in] hProcess

Tipo: HANDLE

Handle per il processo con il PROCESS_QUERY_INFORMATION o PROCESS_QUERY_LIMITED_INFORMATION diritto di accesso. Per altre informazioni, vedere Elaborare diritti di sicurezza e accesso.

[in, out] packageFullNameLength

Tipo: UINT32*

In input, le dimensioni del buffer packageFullName , in caratteri. In output, le dimensioni del nome completo del pacchetto restituito, in caratteri, incluso il terminatore Null.

[out, optional] packageFullName

Tipo: PWSTR

Nome completo 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
APPMODEL_ERROR_NO_PACKAGE
Il processo non ha alcuna identità del pacchetto.
ERROR_INSUFFICIENT_BUFFER
Il buffer non è abbastanza grande per contenere i dati. Le dimensioni necessarie sono specificate da PackageFullNameLength.

Commenti

Per informazioni sui limiti delle dimensioni delle stringhe, vedere Costanti di identità.

Esempio

#define _UNICODE 1
#define UNICODE 1

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

int ShowUsage();
void ShowProcessPackageFullName(__in const UINT32 pid, __in HANDLE process);

int ShowUsage()
{
    wprintf(L"Usage: GetPackageFullName <pid> [<pid>...]\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)
    {
        UINT32 pid = wcstoul(argv[i], NULL, 10);
        if (pid > 0)
        {
            HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
            if (process == NULL)
                wprintf(L"Error %d in OpenProcess (pid=%u)\n", GetLastError(), pid);
            else
            {
                ShowProcessPackageFullName(pid, process);
                CloseHandle(process);
            }
        }
    }
    return 0;
}

void ShowProcessPackageFullName(__in const UINT32 pid, __in HANDLE process)
{
    wprintf(L"Process %u (handle=%p)\n", pid, process);

    UINT32 length = 0;
    LONG rc = GetPackageFullName(process, &length, NULL);
    if (rc != ERROR_INSUFFICIENT_BUFFER)
    {
        if (rc == APPMODEL_ERROR_NO_PACKAGE)
            wprintf(L"Process has no package identity\n");
        else
            wprintf(L"Error %d in GetPackageFullName\n", rc);
        return;
    }

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

    rc = GetPackageFullName(process, &length, fullName);
    if (rc != ERROR_SUCCESS)
        wprintf(L"Error %d retrieving PackageFullName\n", rc);
    else
        wprintf(L"%s\n", fullName);

    free(fullName);
}


Requisiti

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

Vedere anche

GetCurrentPackageFullName

GetPackageFamilyName

GetPackageId

PackageFullNameFromId