本人用VB编写了一个COM组件,然后用Visual C++ 写了一个Service,现在需要在此Service中调用COM组件,把CoInitializeEx、CoCreateInstance、QueryInterface都用遍了,但还是没有什么效果,由于时间较急,请高手指点,最好能给出事例程序。谢谢!
...全文
4795打赏收藏
急,用Visual C++ 如何调用COM组件?
本人用VB编写了一个COM组件,然后用Visual C++ 写了一个Service,现在需要在此Service中调用COM组件,把CoInitializeEx、CoCreateInstance、QueryInterface都用遍了,但还是没有什么效果,由于时间较急,请高手指点,最好能给出事例程序。谢谢!
for the situation that client & server is not one computer, you can try following codes:
call CLSIDFromProgID to get relative class id
call CoCreateInstance to get the dispatch interface pointer for your component Interface
call GetIDsOfNames by your dispatch interface to get method id of some method named by you.
set parameters for your calling
call Invoke by your dispatch to triger your method with your method id & return your result.