Home > Software engineering >  COM how to use in the thread
COM how to use in the thread

Time:10-21

Doing an OPC client needs to use com originally also contact less,
I define a global variable static COPCServer * opcServer; Link under a button it would like to open a thread to determine the state of the server
Use it under the class of opcServer - & gt; GetStatus (status); Function failure return
RPC_E_WRONG_THREAD The application called an interface that was marshalled The mistake to find some information on The Internet, use The
CoMarshalInterThreadInterfaceInStream (IID_ICircle opcServer - & gt; GetServer (), & amp; PStream); But pStream returns null unanswered! Help!
How to solve

CodePudding user response:

In you create the service thread, CoMarshalInterThreadInterfaceInStream method is used to Marshal to the Stream,
Then, using CoGetInterfaceAndReleaseStream for instance in your thread interface,
Use this to capture interface call your method in the thread,
  • Related