本人新手刚接触vb,不太懂这些,求解vb中要怎么使用?
以下是在vb.net中的代码
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=4)>
<MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst:=256, ArraySubType:=UnmanagedType.I1)>
<MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst:=100)>
<System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.Cdecl)>
<DllImport("Sdk.dll")>
<MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst:=100)>
这个可以用
String * 100
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=4)>
这个一般不需要,直接用Type定义结构体
<System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.Cdecl)>
这个VB没法调用,只有stdcall才能调用,cdecl需要借助vc++转了。
<DllImport("Sdk.dll")>
这个用Declare Function 函数名 Lib "sdk.dll" ...
这些是用来定义和c++语言编写的dll交互的结构体和类型用的。
把它们放在你的Structure、Function的定义的前面。就可以。