Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problems accessing COM-Objects

jholzerjholzer Member Posts: 2
Hi!

I have a COM-Object, that is supplied by a commercial company to access certrain devices.
What i try to do is to use this COM-Object to access the hierarchical structure of these devices.

So i plugged in this COM-Object but I do have certrain difficulties accessing them, as the following code shows:

hr = CoCreateInstance( IID_Device, // CLSID of coclass
NULL, // not used - aggregation
CLSCTX_INPROC_SERVER, // type of server
IID_IDevice, // IID of interface
(void**) &pDevice ); // Pointer to our interface pointer

if ( SUCCEEDED ( hr ) )
{
IDvProject * pProject;

hr = CoCreateInstance( IID_DvProject, // CLSID of coclass
NULL, // not used - aggregation
CLSCTX_INPROC_SERVER, // type of server
IID_IDvProject, // IID of interface
(void**) &pProject ); // Pointer to our interface pointer

int count = pProject->Count; // Works an returns correct count of Projects

IUnknown* xy1 = pIProjects->get_enum(); // Delivers point of IUnkwown, which should be IProject
IProject* xy1 = pIProjects->get_enum(); // Delivers pointer to zero, which is not so good

pDevice->Release();
}

What is kind of strange is, that when i do the same in C#/.Net everything works fine and i can browse through all projects and the data collections inside project with a simple foreach-loop.

What do i have to do to make this work in C++/MFC?

Thanks a lot & Greetings

J.
Sign In or Register to comment.