write method
[This documentation is preliminary and is subject to change.]
Writes one or more HTML expressions to a document in the specified window.
Syntax
HRESULT retVal = object.write(psarray);
Standards information
Parameters
psarray [in]
Type: SAFEARRAYA SAFEARRAY of BSTR that specifies the text and HTML tags to write.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
Note When document.write or document.writeln is used in an event handler, you must also use document.close.
Examples
This example shows how to write a string to the document.
IHTMLDocument2 *document; // Declared earlier in the code
BSTR bstr = SysAllocString(OLESTR("Written by IHTMLDocument2::write()."));
// Creates a new one-dimensional array
SAFEARRAY *psaStrings = SafeArrayCreateVector(VT_VARIANT, 0, 1);
if (psaStrings == NULL) {
goto cleanup;
}
VARIANT *param;
HRESULT hr = SafeArrayAccessData(psaStrings, (LPVOID*)¶m);
param->vt = VT_BSTR;
param->bstrVal = bstr;
hr = SafeArrayUnaccessData(psaStrings);
hr = document->write(psaStrings);
cleanup:
// SafeArrayDestroy calls SysFreeString for each BSTR
if (psaStrings != NULL) {
SafeArrayDestroy(psaStrings);
}
See also
Reference
Build date: 1/25/2012