CoCreateInstance HResult is failing, getting error -2147221164 stating that Class is not registered.
-
#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_guidsint 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;
}
-
#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_guidsint 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;
}
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++) -
#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_guidsint 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;
}