The class mshtml.HTMLDocumentClass in Microsoft.mshtml.dll assembly has a method:
public virtual void write(params object[] psarray);
Avoiding
The params keyword indicates that you can supply multiple parameters in this place, and it will group automatically. For example, if I had a function thus:
public int SumNumbers(params int[] value)
{
//Logic.
}
then I could call it like this:
int myValue = SumNumbers(1,2,3,4,5,6,7,8,9,10);
The array is constructed automagically. So hypothetically, you could call
mshtml.HTMLDocumentClass doc;
...
doc.write('H','I',' ','M','O','M');
And it would work. Not really practical though. I suppose you've tried calling
doc.write(myString.ToCharArray());
? I don't know anything about SAFEARRAYS, but its possible you might not have to know, either, depending on how the compiler helps/hinders here.
The declaration for the write method on the IHTMLDocument2 interface created by TLBIMP/VS.NET is incorrect. It should be:
void Write([In, MarshalAs(UnmanagedType.SafeArray)] object[] psarray);
You will have to define this interface in code and then use that.
It works like a charm this way :
[Guid("332C4425-26CB-11D0-B483-00C04FD90119")]
[ComImport]
[TypeLibType((short)4160)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
internal interface IHTMLDocument2
{
[DispId(1054)]
void write([MarshalAs(UnmanagedType.BStr)] string psArray); //modified
//void write([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] object[] psarray); //instead of