Home > Software engineering >  SpUnknown. CoCreateInstance (CLSID_Control); Return a pointer to null
SpUnknown. CoCreateInstance (CLSID_Control); Return a pointer to null

Time:10-08

For COM component interface encapsulation into the COM component DLL, write DLL code is as follows:

 
//start the COM component
CoInitialize (NULL);

CComPtr SpUnknown;
CComPtr SpUnknown1;
CComPtr SpUnknown2;
CComPtr SpUnknown3;

SpUnknown. CoCreateInstance (CLSID_Control);
If (spUnknown==NULL)
{
return false;
}
SpUnknown1. CoCreateInstance (CLSID_Status);
If (spUnknown1==NULL)
{
return false;
}
SpUnknown2. CoCreateInstance (CLSID_Terminal);
If (spUnknown2==NULL)
{
return false;
}
SpUnknown3. CoCreateInstance (CLSID_Utility);
If (spUnknown3==NULL)
{
return false;
}


Call DLL, the return value to false, it is to initialize the COM CoInitialize (NULL);
Don't understand the problem, is it possible to is my registry not registered COM components? But I put in MFC can perform this code, the same can instantiate the pointer object, don't understand!
Pray god give advice or comments!
Pray god give advice or comments!
Pray god give advice or comments!

CodePudding user response:

First look at the error number, so that we can know the specific reason for the error,
  • Related