GetCurrentPackageId function
Gets the package identifier (ID) for the calling process.
Syntax
LONG WINAPI GetCurrentPackageId( _Inout_ UINT32 *bufferLength, _Out_opt_ BYTE *buffer );
Parameters
- bufferLength [in, out]
-
Type: UINT32*
On input, the size of buffer, in bytes. On output, the size of the structure returned, in bytes.
- buffer [out, optional]
-
Type: BYTE*
The package ID, represented as a PACKAGE_ID structure.
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 code | Description |
|---|---|
|
The process has no package identity. |
|
The buffer is not large enough to hold the data. The required size is specified by bufferLength. |
Examples
#define _UNICODE 1 #define UNICODE 1 #include <Windows.h> #include <appmodel.h> #include <malloc.h> #include <stdio.h> int __cdecl wmain() { UINT32 length = 0; LONG rc = GetCurrentPackageId(&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 GetCurrentPackageId\n", rc); return 1; } BYTE * buffer = (BYTE *) malloc(length); if (buffer == NULL) { wprintf(L"Error allocating memory\n"); return 2; } rc = GetCurrentPackageId(&length, buffer); if (rc != ERROR_SUCCESS) { wprintf(L"Error %d retrieving PackageId\n", rc); return 3; } const PACKAGE_ID * packageId = (PACKAGE_ID *) buffer; wprintf(L"Name : %s\n", packageId->name); wprintf(L"Publisher : %s\n", packageId->publisher); wprintf(L"PublisherId : %s\n", packageId->publisherId); wprintf(L"Version : %hu.%hu.%hu.%hu\n", packageId->version.Major, packageId->version.Minor, packageId->version.Build, packageId->version.Revision); wprintf(L"Architecture: %u\n", packageId->processorArchitecture); if (packageId->resourceId != NULL) wprintf(L"Resource : %s\n", packageId->resourceId); free(buffer); return 0; }
Requirements
|
Minimum supported client |
Windows 8 [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2012 [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- GetCurrentPackageFamilyName
- GetCurrentPackageFullName
- GetCurrentPackageInfo
- GetCurrentPackagePath
- GetPackageId
- PackageIdFromFullName
Show: