在多執行緒中使用 IHTMLDocument2 指標

2021-04-25 16:54:00 字數 776 閱讀 4146

問題:

在多執行緒中使用ihtmldocument2 指標會出現錯誤

解決:使用列集,散集來傳遞ihtmldocument2 指標。

宣告全域性變數istream *pstream;

1、將phtmldocument指標傳遞給pstream。

comarshalinterthreadinte***ceinstream(iid_ihtmldocument2, phtmldocument, &pstream);

handle hthread=createthread(null, 0, (lpthread_start_routine)capture, this, 0, null);

2、將pstream傳遞給phtmldocument指標就可以使用了。

uint ccapturedlg::capture(lpvoid p)

{coinitialize(null);

ccapturedlg * self = (ccapturedlg *) p;

ihtmldocument2 *phtmldocument;

hresult hr = ::cogetinte***ceandreleasestream(self->pstream, iid_ihtmldocument2, (void**)&phtmldocument );

bstr   bstr_title, bstr_url;

phtmldocument->get_title(&bstr_title);

phtmldocument->get_url(&bstr_url);

在WPF程式中使用多執行緒技術

在wpf應用程式中使用多執行緒的方式與windows forms很類似,區別在於,如果需要更新主線程ui上面的元素,需要用乙個特殊的方法 this.dispatcher.invoke 下面是乙個簡單的範例,演示了如何執行乙個簡單的方法,它使用了callback的機制進行多執行緒非同步執行。func ...

在WPF程式中使用多執行緒技術

在wpf應用程式中使用多執行緒的方式與windows forms很類似,區別在於,如果需要更新主線程ui上面的元素,需要用乙個特殊的方法 this.dispatcher.invoke 下面是乙個簡單的範例,演示了如何執行乙個簡單的方法,它使用了callback的機制進行多執行緒非同步執行。func ...

c 中使用多執行緒

using system using system.drawing using system.collections using system.componentmodel using system.windows.forms using system.data using system.threa...