How do I run a COM (.ocx) object in a C++ command line interface program. (VS2017)
After many hours of research I have the following. I think the COM object is loading as trio is populated. But I do not know how to run it successfully. It may need to be attached to a CWND or something.
I have this code, which may be the wrong rabbit hole. It crashes horribly.
HRESULT hr;
hr = CoInitialize(0);
assert(SUCCEEDED(hr));
{
static CLSID const clsid
= { 0xf1933967, 0x74b0, 0x11d3,{ 0x8a, 0x13, 0x0, 0x40, 0x33, 0x93, 0xb2, 0x36 } };
//CLSID ClassID;
//hr = CLSIDFromProgID(OLESTR("TrioPCLib.TrioPC"), &ClassID);
assert(SUCCEEDED(hr));
TrioPCLib::_DTrioPCPtr trio;
IID iid = TrioPCLib::_DTrioPCPtr::GetIID();
hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, reinterpret_cast<void**>(&trio));
assert(SUCCEEDED(hr));
trio->Release();
}
CoUninitialize();
The COM object has GUI which I do not need to use it. I just want to call the API.
UPDATE: The ActiveX is loaded and I can call, for example, AboutBox() and it is displayed. It crashes on the CoUninitialize() with an exception...
Unhandled exception at 0x779CA899 (ntdll.dll) in TestVpu.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77A05910).