描述:
编译环境 VS.NET 2003。使用 MSDN 的例子 mfcie 测试。
当页面下载完毕后,开启一线程,在线程中获得页面上的 IMG 元素,想动态更改其 src ,使用 put_src 就会出错
mfcie.exe 中的 0x7ccf9edf 处最可能的异常: 0xC0000005: 读取位置 0x00000034 时发生访问冲突。
但 put_height 、put_alt 等都没有问题,究竟是怎么回事呢?
解决方案1:
试验一把put_src好像不行...
但是setAttribute可以
IHTMLElement::setAttribute Method
Sets the value of the specified attribute.
Syntax
HRESULT setAttribute(\
BSTR strAttributeName,
VARIANT AttributeValue,
LONG lFlags
);
it's should be safe if IHTMLDocument2 interface is marshaled correctly.
i.e. by CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream or via the IGlobalInterfaceTable interface.
see also
http://vcfaq.mvps.org/com/1.htm
用IHTMLDocument