Función GetPackageFullName (appmodel.h)

Obtiene el nombre completo del paquete para el proceso especificado.

Sintaxis

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

Parámetros

[in] hProcess

Tipo: HANDLE

Identificador del proceso que tiene el derecho de acceso PROCESS_QUERY_INFORMATION o PROCESS_QUERY_LIMITED_INFORMATION . Para obtener más información, consulte Derechos de acceso y seguridad de procesos.

[in, out] packageFullNameLength

Tipo: UINT32*

En la entrada, el tamaño del búfer packageFullName , en caracteres. En la salida, se devuelve el tamaño del nombre completo del paquete, en caracteres, incluido el terminador null.

[out, optional] packageFullName

Tipo: PWSTR

Nombre completo del paquete.

Valor devuelto

Tipo: LONG

Si la función se realiza correctamente, devuelve ERROR_SUCCESS. De lo contrario, la función devuelve un código de error. Los posibles códigos de error incluyen lo siguiente.

Código devuelto Descripción
APPMODEL_ERROR_NO_PACKAGE
El proceso no tiene ninguna identidad de paquete.
ERROR_INSUFFICIENT_BUFFER
El búfer no es lo suficientemente grande como para contener los datos. PackageFullNameLength especifica el tamaño necesario.

Comentarios

Para obtener información sobre los límites de tamaño de cadena, consulte Constantes de identidad.

Ejemplos

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


Requisitos

Requisito Value
Cliente mínimo compatible Windows 8 [solo aplicaciones de escritorio]
Servidor mínimo compatible Windows Server 2012 [solo aplicaciones de escritorio]
Plataforma de destino Windows
Encabezado appmodel.h
Library Kernel32.lib
Archivo DLL Kernel32.dll

Vea también

GetCurrentPackageFullName

GetPackageFamilyName

GetPackageId

PackageFullNameFromId