GetPackagesByPackageFamily function
Gets the packages with the specified family name for the current user.
Syntax
LONG WINAPI GetPackagesByPackageFamily( _In_ PWSTR packageFamilyName, _Inout_ UINT32 *count, _Out_opt_ PWSTR *packageFullNames, _Inout_ UINT32 *bufferLength, _Out_opt_ WCHAR *buffer );
Parameters
- packageFamilyName [in]
-
Type: PWSTR
The package family name.
- count [in, out]
-
Type: UINT32*
On input, the size of the packageFullNames buffer, in bytes. On output, the number of package full names returned.
- packageFullNames [out, optional]
-
Type: PWSTR*
The package full names.
- bufferLength [in, out]
-
Type: UINT32*
On input, the size of buffer, in bytes. On output, the size of the package full names returned, in bytes.
- buffer [out, optional]
-
Type: WCHAR*
The package full names.
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 |
|---|---|
|
One or more buffer is not large enough to hold the data. The required size is specified by either count or buffer. |
Examples
#define _UNICODE 1 #define UNICODE 1 #include <Windows.h> #include <appmodel.h> #include <malloc.h> #include <stdio.h> int ShowUsage(); void LookupFamilyName(__in PCWSTR familyName); int ShowUsage() { wprintf(L"Usage: GetPackagesByPackageFamily <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) LookupFamilyName(argv[i]); return 0; } void LookupFamilyName(__in PCWSTR familyName) { wprintf(L"Family Name: %s\n", familyName); UINT32 count = 0; UINT32 length = 0; LONG rc = GetPackagesByPackageFamily(familyName, &count, NULL, &length, NULL); if (rc == ERROR_SUCCESS) { wprintf(L"No packages found\n"); return; } else if (rc != ERROR_INSUFFICIENT_BUFFER) { wprintf(L"GetPackagesByPackageFamily failed with error %d\n", rc); return; } PWSTR * fullNames = (PWSTR *) malloc(count * sizeof(*fullNames)); if (fullNames == NULL) { wprintf(L"Memory allocation failed\n"); return; } PWSTR buffer = (PWSTR) malloc(length * sizeof(WCHAR)); if (buffer == NULL) { wprintf(L"Memory allocation failed\n"); return; } rc = GetPackagesByPackageFamily(familyName, &count, fullNames, &length, buffer); if (rc != ERROR_SUCCESS) wprintf(L"GetPackagesByPackageFamily failed with error %d\n", rc); else { for (UINT32 i = 0; i < count; ++i) wprintf(L"%u: Full name = %s\n", i, fullNames[i]); } free(buffer); free(fullNames); }
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/15/2012