Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Сети";
Текущий архив: 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
1-90993
harismatik
2002-03-15 13:22
2002.03.28
Позиционирование курсора в компоненте TEdit


6-91032
Beginer
2001-11-12 08:43
2002.03.28
Подключить сетевой диск...


1-90853
kull
2002-03-16 20:36
2002.03.28
тестирование...


1-90946
Irina Lisova
2002-03-13 19:06
2002.03.28
TreeView как распечатать дерево ?


1-90836
lipskiy
2002-03-15 15:23
2002.03.28
TWebBrowser: как программно подсунуть ему ссылку на выполнение кода в самой программе?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский