Export (0) Print
Expand All

GetPackagePathByFullName function

Gets the path of the specified package.

Syntax


LONG WINAPI GetPackagePathByFullName(
  _In_       PCWSTR packageFullName,
  _Inout_    UINT32 *pathLength,
  _Out_opt_  PWSTR path
);

Parameters

packageFullName [in]

Type: PCWSTR

The full name of the package.

pathLength [in, out]

Type: UINT32*

A pointer to a variable that holds the number of characters (WCHARs) in the package path string, which includes the null-terminator.

First you pass NULL to path to get the number of characters. You use this number to allocate memory space for path. Then you pass the address of this memory space to fill path.

path [out, optional]

Type: PWSTR

A pointer to memory space that receives the package path 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_INSUFFICIENT_BUFFER

The buffer specified by path is not large enough to hold the data. The required size is specified by pathLength.

 

Examples



#define _UNICODE 1
#define UNICODE 1

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

int ShowUsage();
void FullNameToPath(__in PCWSTR fullName);
int ShowUsage()
{
    wprintf(L"Usage: GetPackagePathByFullName <fullname> [<fullname>...]\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)
    {
        FullNameToId(argv[i]);
    }

    return 0;
}

void FullNameToPath(__in PCWSTR fullName)
{
    wprintf(L"FullName: %s\n", fullName);
    UINT32 length = 0;
    LONG rc = GetPackagePathByFullName(fullName, &length, NULL);
    if (rc == ERROR_SUCCESS)
    {
        wprintf(L" GetPackagePathByFullName unexpectedly succeeded\n");
        return;
    }
    else if (rc != ERROR_INSUFFICIENT_BUFFER)
    {
        wprintf(L"Error %d in GetPackagePathByFullName\n", rc);
        return;
    }

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

    rc = GetPackagePathByFullName(fullName, &length, path);
    if (rc != ERROR_SUCCESS)
        wprintf(L"Error %d retrieving Package's path\n", rc);
    else
        wprintf(L"Path = %s\n", path);

    free(path);
}


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