Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. CoCreateInstance HResult is failing, getting error -2147221164 stating that Class is not registered.

CoCreateInstance HResult is failing, getting error -2147221164 stating that Class is not registered.

Scheduled Pinned Locked Moved COM
helpc++json
3 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pallaka
    wrote on last edited by
    #1

    #include "stdafx.h" #include "windows.h" Hi All, In the below mentioned code. i want to use MSCOMM32.OCX file API to my C++ code. i am facing an issue when i am getting HResult from the cocreateInstance. Kindly let me know what should i do to access MSCOMM32.OCX API.

    #include "atlbase.h"
    //#include "mscomm32.tlh"
    #import "C:\\WINDOWS\\system32\\MSCOMM32.OCX" no_namespace raw_interfaces_only raw_native_types no_implementation named_guids

    int main(int argc, _TCHAR* argv[])
    {
    GUID iid = {0xE6E17E90, 0xDF38, 0x11CF, 0x8E, 0x74,0x00,0xA0,0xC9,0x0F,0x26,0xF8};
    GUID Clsid = {0x648A5603, 0x2C6E, 0x101B, 0x82, 0xB6, 0x0,0x0, 0x0, 0x0, 0x0, 0x14};
    IMSComm **ppv = 0;
    HRESULT hRet = 0;
    hRet = CoInitialize(NULL);
    hRet = CoCreateInstance (Clsid, NULL,CLSCTX_LOCAL_SERVER,iid,(void**)&ppv);

     \_bstr\_t pbstrSettings("9600,N,8,1");
     (\*ppv)->put\_PortOpen(1);
     (\*ppv)->put\_Settings(pbstrSettings);
     (\*ppv)->AboutBox();
    
    return 0;
    

    }

    _ V 2 Replies Last reply
    0
    • P pallaka

      #include "stdafx.h" #include "windows.h" Hi All, In the below mentioned code. i want to use MSCOMM32.OCX file API to my C++ code. i am facing an issue when i am getting HResult from the cocreateInstance. Kindly let me know what should i do to access MSCOMM32.OCX API.

      #include "atlbase.h"
      //#include "mscomm32.tlh"
      #import "C:\\WINDOWS\\system32\\MSCOMM32.OCX" no_namespace raw_interfaces_only raw_native_types no_implementation named_guids

      int main(int argc, _TCHAR* argv[])
      {
      GUID iid = {0xE6E17E90, 0xDF38, 0x11CF, 0x8E, 0x74,0x00,0xA0,0xC9,0x0F,0x26,0xF8};
      GUID Clsid = {0x648A5603, 0x2C6E, 0x101B, 0x82, 0xB6, 0x0,0x0, 0x0, 0x0, 0x0, 0x14};
      IMSComm **ppv = 0;
      HRESULT hRet = 0;
      hRet = CoInitialize(NULL);
      hRet = CoCreateInstance (Clsid, NULL,CLSCTX_LOCAL_SERVER,iid,(void**)&ppv);

       \_bstr\_t pbstrSettings("9600,N,8,1");
       (\*ppv)->put\_PortOpen(1);
       (\*ppv)->put\_Settings(pbstrSettings);
       (\*ppv)->AboutBox();
      
      return 0;
      

      }

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      The activeX is probably not registered. Which OS are you using? Open a command prompt with admin privileges, change to the system32 directory and type the command regsvr32 mscomm32.ocx.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      1 Reply Last reply
      0
      • P pallaka

        #include "stdafx.h" #include "windows.h" Hi All, In the below mentioned code. i want to use MSCOMM32.OCX file API to my C++ code. i am facing an issue when i am getting HResult from the cocreateInstance. Kindly let me know what should i do to access MSCOMM32.OCX API.

        #include "atlbase.h"
        //#include "mscomm32.tlh"
        #import "C:\\WINDOWS\\system32\\MSCOMM32.OCX" no_namespace raw_interfaces_only raw_native_types no_implementation named_guids

        int main(int argc, _TCHAR* argv[])
        {
        GUID iid = {0xE6E17E90, 0xDF38, 0x11CF, 0x8E, 0x74,0x00,0xA0,0xC9,0x0F,0x26,0xF8};
        GUID Clsid = {0x648A5603, 0x2C6E, 0x101B, 0x82, 0xB6, 0x0,0x0, 0x0, 0x0, 0x0, 0x14};
        IMSComm **ppv = 0;
        HRESULT hRet = 0;
        hRet = CoInitialize(NULL);
        hRet = CoCreateInstance (Clsid, NULL,CLSCTX_LOCAL_SERVER,iid,(void**)&ppv);

         \_bstr\_t pbstrSettings("9600,N,8,1");
         (\*ppv)->put\_PortOpen(1);
         (\*ppv)->put\_Settings(pbstrSettings);
         (\*ppv)->AboutBox();
        
        return 0;
        

        }

        V Offline
        V Offline
        Vi2
        wrote on last edited by
        #3

        pallaka wrote:

        hRet = CoCreateInstance (Clsid, NULL,CLSCTX_LOCAL_SERVER,iid,(void**)&ppv);

        As a rule, OCX is an in-proc server.

        With best wishes, Vita

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups