void __fastcall tform1::sethtml( tcppwebbrowser *webbrowser,ansistring html )
{
istream *stream;
hglobal hhtmltext;
ipersiststreaminit *psi;
if( webbrowser->document == null )
return;
hhtmltext = globalalloc( gptr, html.length() + 1 );
if( 0 == hhtmltext ) {
showmessage( "globalalloc error" );
return;
}
copymemory( hhtmltext, html.c_str(), html.length() );
olecheck( createstreamonhglobal( hhtmltext, true, &stream ) );
try {
olecheck( webbrowser->document->queryinterface( __uuidof(ipersiststreaminit), (void **)&psi ) );
try {
olecheck( psi->initnew() );
olecheck( psi->load(stream) );
} catch( ... ) {
delete psi;
}
} catch( ... ) {
delete stream;
}
delete psi;
delete stream;
}