.NET mshtml: How to pass a BSTR SAFEARRAY?

前端 未结 3 1306
孤独总比滥情好
孤独总比滥情好 2021-01-22 12:21

The class mshtml.HTMLDocumentClass in Microsoft.mshtml.dll assembly has a method:

public virtual void write(params object[] psarray);

Avoiding

3条回答
  •  不思量自难忘°
    2021-01-22 12:39

    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.

提交回复
热议问题