C语言函数声明:
__declspec(dllexport) int __stdcall test1(int a,const char* str);
__declspec(dllexport) void __stdcall test2(unsigned char* buf,int len);
VB.NET调用C语言函数:
'下面这句不能少
Imports System.Runtime.InteropServices
'函数声明,如果是在类中声明,则需要在Function/Sub前加Shared关键字修饰
<DllImport("test.dll", EntryPoint:="test1")>
Public Function test1(ByVal a As Integer, ByVal str As String) As Integer
End Function
<DllImport("test.dll", EntryPoint:="test2")>
Public Sub test2(ByVal buf() As Byte, ByVal len As Integer)
End Sub
'Main函数中调用示例:
Console.WriteLine(test1(123, "张三"))
Dim img() As Byte
img(0)=11
img(1)=12
img(2)=13
test2(img, 3)