Форум: "Сети";
Текущий архив: 2002.03.28;
Скачать: [xml.tar.bz2];
ВнизДоспуп к свойтвам Internet Explorer (СОМ) при работе с SHTTP, а работа с СОМ при использовании потоков Найти похожие ветки
← →
kig (2002-01-16 19:31) [10]Если хотите использовать в потоке (например Б) COM-объект, созданный в другом потоке (А), и объект не ThreadingModel != Free (Both), необходимо проделать примерно следующее:
1. в потоке Б вызвать CoInitialize (или CoInitializeEx)
2. в потоке А выполнить
CoMarshalInterThreadInterfaceInStream
Marshals an interface pointer from one thread to another thread in the same process.
HRESULT CoMarshalInterThreadInterfaceInStream(
REFIID riid, //Reference to the identifier of the interface
LPUNKNOWN pUnk, //Pointer to the interface to be marshaled
LPSTREAM * ppStm //Address of output variable that receives the
// IStream interface pointer for the marshaled
// interface
);
например CoMarshalInterThreadInterfaceInStream(WebBrowser.Document)
3. В потоке Б выполнить
Забрать ppStm и использовать его в
CoGetInterfaceAndReleaseStream
Unmarshals a buffer containing an interface pointer and releases the stream when an interface pointer has been marshaled from another thread to the calling thread.
HRESULT CoGetInterfaceAndReleaseStream(
LPSTREAM pStm, //Pointer to the stream from which the object is
// to be marshaled
REFIID riid, //Reference to the identifier of the interface
LPVOID * ppv //Address of output variable that receives the
// interface pointer requested in riid
);
Затем пользовать ppv (как WebBrowser.Document)
4. В потоке Б перед окончание вызвать CoUninitialize
Читать лучше первоисточники ))
MSDN
Platform SDK
Component service
COM
Страницы: 1 вся ветка
Форум: "Сети";
Текущий архив: 2002.03.28;
Скачать: [xml.tar.bz2];
Память: 0.44 MB
Время: 0.006 c