DLL原型
short GetNumber( byte Msg[31] );
说明:
cardNo[31]: 0-11是卡号,12-13是时间,14-30操作员
关键是C#调用时参数如何传递。
short GetNumber( byte Msg[31] );
说明:
cardNo[31]: 0-11是卡号,12-13是时间,14-30操作员
关键是C#调用时参数如何传递。
其它代码就能直接当自己的函灵敏调用了
[DllImport(...)]
extern static Int16 GetNumber( byte[] Msg );
下面是一个调用API函数的例子:
[DllImport("KERNEL32.DLL", EntryPoint="MoveFileW", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool MoveFile(String src, String dst); 你直接用MoveFile方法就行了
DLL原型
short GetNumber( byte Msg[31] );
说明:
cardNo[31]: 0-11是卡号,12-15是时间,16-30操作员
如
卡号 = "12345";
时间 = "2006-12-1";
操作员 = "TEST";
如何将写这个DEMO。快,很急。
for(int k=0;k<bb.Length;k++)
bb[k] =(byte)k;
short sh = GetNumber(bb);
问题在于数据转到byte[]的格式
byte[] bData = Encoding.ASCII.GetBytes( yourString );至于整合,通过Array.Copy来合并。
说明:
cardNo[31]: 0-11是卡号,12-15是时间,16-30操作员
如
卡号 = "12345";
时间 = "2006";
操作员 = "TEST1";
+++++++++++++++++++++++++++++++
好像你这样做有点问题.我给你看一下我的引用,请指点.
[DllImport("Test.DLL")]
public static extern short GetNumber( ref System.Text.StringBuilder strMsg );调用:
public staitc short TestDll()
{
StringBulider st = new StringBulider("1234500000002006TEST1");
short i = GetNumber( ref System.Text.StringBuilder strMsg )
return i;
}
您帮我看一下我这样做问题出在哪里,谢谢。
说明:原DLL中的传入参数是引参,不是值参,所以我用了"ref".
以上DLL说明中提供了一个VFP的调用例子,如下
declare short GetNumber in TestDll;
string @Msg
Knight94(愚翁)
short GetNumber( byte Msg[31] );
说明:
cardNo[31]: 0-11是卡号,12-15是时间,16-30操作员
如
卡号 = "12345";
时间 = "2006";
操作员 = "TEST1";
+++++++++++++++++++++++++++++++
好像你这样做有点问题.我给你看一下我的引用,请指点.
[DllImport("Test.DLL")]
public static extern short GetNumber( ref System.Text.StringBuilder strMsg );调用:
public staitc short TestDll()
{
StringBulider st = new StringBulider("1234500000002006TEST1");
short i = GetNumber( ref st )
return i;
}
您帮我看一下我这样做问题错在哪里,谢谢。
说明:原DLL中的传入参数是引参,不是值参,所以我用了"ref".
以上DLL说明中提供了一个VFP的调用例子,如下
declare short GetNumber in TestDll;
string @Msg
群内高手为您解疑
群号 : 11623794