<p>C# 如何调用VB6.0编写的dll
/*---------------VB Dll代码如下-------------------------*/</p><p> </p>
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Class1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Function jia(a As Integer, b As Integer, c As Integer) As Boolean
If a = 1 And b = 2 And c = 3 Then
jia = True
End If
End Function
//
调用步骤如下:
1. Copy *.dll to windows\system32
2. 注册*.dll (在system32目录下运行regsvr32 *.dll)
3. C# project 添加引用,在COM组件里可以找到已经注册的*.dll组件名称,选中后点击确定
4. C# 添加 using *
/*------------------------C# 调用代码如下-----------------------------------*/
private void button1_Click(object sender, EventArgs e)
{
jiafa.Class1 add = new Class1();
if (add.jia(1, 2, 3))
MessageBox.Show("成功调用VB dll");
}