I immediately tried the code pasting method shared by dudu. The result is really good. Unfortunately, my computer only has Office XP, so there is no color.
As for this snippet, it is used to demonstrate how to call a COM component written in. NET in VB6, and pass in, out, and return a ByteArray.
In fact, the code written is very simple, but it was really troublesome at the beginning because I couldn't find it. the corresponding Attribute (mainly InAttribute, OutAttribute, corresponding keyword in, out, ref, and IDL definitions in. NET.
Now let me think about the attribute [return: financialas ()], which may not need to be added. You can give me a try.
Using System;
Using System. Runtime. InteropServices;
Namespace expose_to_COM
{
Public interface IInfo
{
[
Return: financialas (UnmanagedType. SafeArray)
]
Byte [] GetBytes (ref byte [] bytes );
}
[ClassInterface (ClassInterfaceType. None)]
Public class Class1: IInfo
{
Public Class1 ()
{
}
Public byte [] GetBytes (ref byte [] bytes)
{
Byte [] _ bytes = new byte [] {0x30, 0x31,0x32, 0x00 };
Return _ bytes;
}
}
}