'Instantiation IGroupPolicyObject fiailed with 0x800736B1

I want to set some config for group policy, using code found on the internet.

::CoInitialize(NULL);
IGroupPolicyObject* pObj = NULL;
            hr = CoCreateInstance(CLSID_GroupPolicyObject, NULL, CLSCTX_INPROC_SERVER, IID_IGroupPolicyObject, (LPVOID *)&pObj);
            if (FAILED(hr))
            {
                // hr = print
                break;
            }

As I run this in my win10 it works.But when I use the same code in win7, CoCreateInstance returns 0x800736B1 and IGroupPolicyObject instantiation failed.

I thought gpedit.dll version is too old, but I run in server2008 it works.

And I follow the errcode using sxstrace.exe, the log shows:

INFO: Parsing Manifest File C:\Windows\System32\GPEdit.dll. INFO: Manifest Definition Identity is (null). ERROR: Activation Context generation failed. End Activation Context Generation.

Not useful for me.

Maybe some services is not running? I don't know. Any thoughts much thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source