在做一個關于OPC 的客戶端需要用到com 原來也接觸的少。
我定義了一個全域的變數 static COPCServer *opcServer; 在一個按鈕下鏈接了它想開一個執行緒判斷服務器的狀態
使用它類下的 opcServer->getStatus(status); 函式失敗回傳
RPC_E_WRONG_THREAD The application called an interface that was marshalled 這個錯誤在網上找了些資料說是使用
CoMarshalInterThreadInterfaceInStream(IID_ICircle, opcServer->getServer(), &pStream); 但是pStream 回傳null 無解啦求助啊
要怎么解決
uj5u.com熱心網友回復:
在你創建服務的執行緒中,使用 CoMarshalInterThreadInterfaceInStream 方法 Marshal 到 Stream。然后,在你的執行緒中使用 CoGetInterfaceAndReleaseStream 獲取實體介面。
使用這個在執行緒中獲取的介面呼叫你的方法。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/134097.html
上一篇:離散傅里葉變換問題
下一篇:在vc上模擬GUI的萬年歷
