Home > Software engineering >  How to call the third party of COM components? Need to know what information?
How to call the third party of COM components? Need to know what information?

Time:10-03

Soon after contact with COM components, according to the online tutorial using ATL templates got a COM component, create a class, add the method and register, then written in MFC executable calls to the method of COM component interface (function), running through no problem,
Project requirement is that I want to be a general detection software, testing of multiple manufacturers COM component, the COM component is a specification in accordance with the industry to provide a set of function interface, the function name and parameters are fixed, each manufacturer are consistent, internal implementation,
I want to use a test software, the DLL runtime choose different manufacturer, can call to the manufacturer of the COM component interface function, so first of all, each manufacturer COM DLL file name is uncertain, # import * * * *. DLL no_namespace here to see if there is trouble? Manufacturers and, more importantly, the COM components in the name of the class are not sure, can't import when writing a test software, the Internet search the invocation of the method are:
CLSIDFromProgID (OLESTR (" myCom GetRes "), & amp; Clsids);
CComPtr PGetRes;//the practical situation of smart Pointers IGetRes uncertain
PGetRes. CoCreateInstance (clsids);
PGetRes - & gt; Hello ();

ProgID information such as perhaps check, the test program is running in, but IGetRes this class interface name test program compile time is set, the runtime can't change,
If each manufacturer COM component class interface name, file name is unknown, that this way is ok? How should the dynamic invocation?

CodePudding user response:

Learn how to use OleView. Exe

CodePudding user response:

reference 1st floor zhao4zhong1 response:
. Learn to use OleView exe


Thank you very much!
Run OleView. Exe can see registered COM component information,
But when write the upper test program is not for COM component files, don't know the third party class interface of COM components, the code is bad to write,
For example,
Retrieves the hr=CLSIDFromProgID (OLESTR (" myCom. GetRes "), & amp; Clsids);
IGetRes * PTR.
Hr=CoCreateInstance (clsids, NULL, CLSCTX_INPROC_SERVER,
__uuidof (IGetRes), (LPVOID *) & amp; PTR);
This method is called, did you get the COM component files before IGetRes this name all don't know, how to solve?

CodePudding user response:

Interfaces are based on the IDispatch?
Within the DLL containing the type library?

CodePudding user response:

Third party libraries need documents to describe, this also is the so-called the SDK

CodePudding user response:

Dobzhansky
reference 3 floor response:
interfaces are based on the IDispatch?
Within the DLL containing the type library?

I got COM component interface is based on the IDispatch,
Now in the QueryInterface then invoke method can circumvent the interface name, do not know too much, just contact
Other vendors COM how I don't know,

CodePudding user response:

If you have a type library, can get all the information, and if the IDispatch, need not can call a header file

CodePudding user response:

I give you a way,
When we have a requirement, according to the different hardware to invoke the different COM, similar to the hardware driver, but not drive,
Each kind of equipment to provide programs you need COM clsids,
According to the clsids directly create an instance, return to the interface,
After using this interface, and the specific is that COM has nothing to do,

CodePudding user response:

The
reference 7 floor Saleayas response:
I give you a way,
When we have a requirement, according to the different hardware to invoke the different COM, similar to the hardware driver, but not drive,
Each kind of equipment to provide programs you need COM clsids,
According to the clsids directly create an instance, return to the interface,
After using this interface, it has nothing to do with concrete is that COM,

Yes, my applications like you said! Manufacturers of COM components and their hardware communication, I write detection software call them respectively,
Problem now don't know a few vendors (perhaps gradually increase) component interface name also don't know them, some things can be in the test software runtime to obtain, such as clsids, the IID of the interface, but detection software programming, as if must know the interface name, otherwise CComPtr PGetRes; Or IGetRes * PTR. Such code is bad to write, also can't correctly through the virtual function table function call,
You said "" from clsids directly create an instance, return to the interface" ", is to return the interface pointer or something? Light has interface pointer, don't know the interface name cannot be instantiated to access the member function? Can you say detail
  • Related