I am getting the error “No such interface supported” when I call the CoCreateInstance() in dll. I am trying to create an instance of IGroupPolicyObject. When I run this sample code snippet through exe it returns S_OK but if I run through DLL then I get an error.
I have added the sample code snippet.
HRESULT hr =S_OK;
IGroupPolicyObject* pLGPO = NULL;
// MSVC is finicky about these ones => redefine them
const IID my_IID_IGroupPolicyObject =
{ 0xea502723, 0xa23d, 0x11d1, {0xa7, 0xd3, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3} };
const IID my_CLSID_GroupPolicyObject =
{ 0xea502722, 0xa23d, 0x11d1, {0xa7, 0xd3, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3} };
GUID ext_guid = REGISTRY_EXTENSION_GUID;
// This next one can be any GUID you want
GUID snap_guid = { 0x3d271cfc, 0x2bc6, 0x4ac2, {0xb6, 0x33, 0x3b, 0xdf, 0xf5, 0xbd, 0xab, 0x2a} };
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
// Create an instance of the IGroupPolicyObject class
hr = CoCreateInstance(my_CLSID_GroupPolicyObject,
NULL,
CLSCTX_INPROC_SERVER,
my_IID_IGroupPolicyObject,
(LPVOID*)&pLGPO
);
if (SUCCEEDED(hr))
{
hr = pLGPO->OpenLocalMachineGPO( GPO_OPEN_LOAD_REGISTRY);
}
Please tell me am I doing anything wrong?
Source: dll