News:
|
|
|
|
|
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ComTestCSharp
{
[Guid("F1E80D2D-72F7-434F-86AB-DFC7BF10C447")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[ComVisible(true)]
public interface IComTest
{
[DispId(1)]
int AddFunction(int value1, int value2);
[DispId(2)]
string GetMyProperty();
[DispId(3)]
string MyProperty { get; set; }
}
[Serializable]
[Guid("0C216A19-E1B7-4b05-86D3-4C516BDDC041")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
[ProgId("ComTest")]
public class ComTest : IComTest
{
public string MyProperty { get; set; }
public ComTest() { }
public int AddFunction(int value1, int value2)
{
return value1 + value2;
}
public string GetMyProperty()
{
MessageBox.Show("MyProperty: "+MyProperty);
return MyProperty;
}
}
}
Function MyTest()
Dim test As Long
Dim theObj As New ComTest
test = theObj.AddFunction(5, 6)
theObj.MyProperty = "Test"
Dim strValue As String
strValue = theObj.GetMyProperty()
Exit Function
End Function
|