When using the Win32 GetAppliedGPOList in C, the GPO list pointer is always NULL even when trying multiple GUIDs and even when the API returns success.

Madden, John 5 Reputation points
2024-07-24T12:56:07.7066667+00:00

In the code below, pGPOList (the GPO list) is always NULL even when the GetAppliedGPOList returns success. I have tried multiple group policy extension GUIDs, but no luck. What am I doing wrong? This also happens when I try GetAppliedGPOList with user policies, although the code is slightly different.

static DWORD DisplayAppliedMachinePolicies()

{

PGROUP_POLICY_OBJECT  pGPOList = NULL;

LPGROUPPOLICYOBJECT pGPO = NULL;

UUID guid;

DWORD dwError = 0;

//{17D89FEC-5C44-4972-B12D-241CAEF74509}

//{3A0DBA37-F8B2-4356-83DE-3E90BD5C261F}

//{E47248BA-94CC-49c4-BBB5-9EB7F05183D0}

if (string_to_guid(L"E47248BA-94CC-49c4-BBB5-9EB7F05183D0", &guid) != 0)

{

    return ERROR_BAD_FORMAT;

}

dwError = GetAppliedGPOList(GPO_LIST_FLAG_MACHINE, NULL, NULL, &guid, &pGPOList);

if (dwError == ERROR_SUCCESS)

{

    PGROUP_POLICY_OBJECT pGPO = (PGROUP_POLICY_OBJECT)pGPOList;

    while (pGPO != NULL)

    {

        //Display properties of each GPO

        DisplayPolicyInfo((PGROUP_POLICY_OBJECT)&pGPOList);

        pGPO = pGPO->pNext;

    }

    FreeGPOList((PGROUP_POLICY_OBJECT)pGPOList);

}



return dwError;

}

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,189 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,650 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,758 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 85,806 Reputation points
    2024-07-24T14:23:51.06+00:00

    I did a loop on keys at "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions"(RegOpenKeyEx/RegEnumKey)

    and I got some != NULL

    (

    {35378EAC-683F-11D2-A89A-00C04FBBCFA2}

    or

    {F312195E-3D9D-447A-A3F5-08DFFA24735E}

    on my PC)

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.