Function Integer DC_Mif_Read(Integer bAddr ,Ref String bData ) Library "Fox_DC.dll"
Function Integer DC_Mif_Write(Integer bAddr , Ref String bData ) Library "Fox_DC.dll"这两个函数是PB中的声明说明如下:DC_Mif_Write
DC_Mif_Write 函数向卡片内的指定块地址写入一字符串。WORD DC_Mif_Write
(
BYTE _bAdr,
BYTE *_bData
);
参数
_bAdr 要写入的块地址。对于Mifare S50卡,其范围为(1 - 63),对于Mifare L10卡,其范围为(2 - 11), Mifare 1102 其范围是(2 – 15);Token其范围是(2 – 15)。 _bData 无符号字符型指针,其内容为要写入到卡片内的ASC码形式的字符串。Mifare S50应确保已分配给_bData指针至少32个字节的空间,其余8字节就好。 返回值
如果函数调用成功,返回值为0。如果函数调用失败,返回值不为0。如需得到错误描述,请调用DC_GetLastError。DC_Mif_Read
DC_Mif_Read 函数从卡片内的指定块地址读取一字符串。WORD DC_Mif_Read
(
BYTE _bAdr,
BYTE *_bData
)
参数
_bAdr要读取的块地址。对于Mifare S50卡,其范围为(0 - 63);对于Mifare L10卡,其范围为(0 - 11),其中有连续两个块读的内容是一样的;Mifare 1102 其范围是(0 – 15);Token其范围是(0 – 15)。 _bData 无符号字符型指针,指向从卡片存储区内读到的字符串的ASC码并返回给应用程序。读Mifare S50的卡应确保已分配给_bData指针至少32个字节的空间,Mifare L10 至少16字节空间,其余8字节就可。 返回值
如果函数调用成功,返回值为0。如果函数调用失败,返回值不为0。如需得到错误描述,请调用DC_GetLastError。
请问在C#中如何调用?????
Function Integer DC_Mif_Write(Integer bAddr , Ref String bData ) Library "Fox_DC.dll"这两个函数是PB中的声明说明如下:DC_Mif_Write
DC_Mif_Write 函数向卡片内的指定块地址写入一字符串。WORD DC_Mif_Write
(
BYTE _bAdr,
BYTE *_bData
);
参数
_bAdr 要写入的块地址。对于Mifare S50卡,其范围为(1 - 63),对于Mifare L10卡,其范围为(2 - 11), Mifare 1102 其范围是(2 – 15);Token其范围是(2 – 15)。 _bData 无符号字符型指针,其内容为要写入到卡片内的ASC码形式的字符串。Mifare S50应确保已分配给_bData指针至少32个字节的空间,其余8字节就好。 返回值
如果函数调用成功,返回值为0。如果函数调用失败,返回值不为0。如需得到错误描述,请调用DC_GetLastError。DC_Mif_Read
DC_Mif_Read 函数从卡片内的指定块地址读取一字符串。WORD DC_Mif_Read
(
BYTE _bAdr,
BYTE *_bData
)
参数
_bAdr要读取的块地址。对于Mifare S50卡,其范围为(0 - 63);对于Mifare L10卡,其范围为(0 - 11),其中有连续两个块读的内容是一样的;Mifare 1102 其范围是(0 – 15);Token其范围是(0 – 15)。 _bData 无符号字符型指针,指向从卡片存储区内读到的字符串的ASC码并返回给应用程序。读Mifare S50的卡应确保已分配给_bData指针至少32个字节的空间,Mifare L10 至少16字节空间,其余8字节就可。 返回值
如果函数调用成功,返回值为0。如果函数调用失败,返回值不为0。如需得到错误描述,请调用DC_GetLastError。
请问在C#中如何调用?????
解决方案 »
- 最近在想那个怎么用.net写个程序用来无限发送QQ漂流瓶啊?
- winform 按扭问题!
- 有关C#的异常处理
- winform中如何ping一个ip,看它是否有效?
- c# 中Array类是否默认实现了Icompareble接口啊不要我们去显示实现吧?
- 菜鸟求教下面这段关于byte[]的代码的含义。解释清楚明白就给分!
- 编程中在移植程序时,如何处理链接地址变化的问题?
- C# TcpListener 监听自动停止(急急急)
- 有人知道如何在Microsoft Visual Studio 2008中用c#语言引用dll插件的吗?
- 谁有关于进程的资料?
- 在线求助,winform中,label1.Enable = false;字体颜色怎么办?
- C# WinForm 的location属性设定
[DllImport("FOX_DC.dll", EntryPoint = "DC_Mif_Write", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int DC_Mif_Write(UInt16 bAddr,ref StringBuilder bData);写的时候没出什么错误,倒是可以写进卡里
但读的时候,读出来的是空
DC_Mif_Read函数该如何调用??
Public Declare Function DC_Mif_Read Lib "Fox_DC" (ByVal bAddr As Byte, ByVal bData As String) As IntegerPublic Declare Function DC_Mif_Write Lib "Fox_DC" (ByVal bAddr As Byte, ByVal bData As String) As Integer
public static extern int DC_Mif_Read(int bAddr,string bData);
[DllImport("FOX_DC.dll", EntryPoint = "DC_Mif_Write", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int DC_Mif_Write(int bAddr,string bData); 这样试试
[DllImport("FOX_DC.dll", EntryPoint = "DC_Mif_Read", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int DC_Mif_Read(int bAddr,string bData);
这样定义的话,读到的值没法返回
public static extern int DC_Mif_Read(int bAddr,ref string bData); 这样试试呢?
public static extern int DC_Mif_Read(UInt16 bAddr,ref string bData); string udd = "";
DC_Mif_Read(0, ref udd);到这句就出错了
引发类型为“System.ExecutionEngineException”的异常。
大家帮忙
[DllImport("FOX_DC.dll", EntryPoint = "DC_Mif_Read", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int DC_Mif_Read(int bAddr,ref string bData);
引发类型为“System.ExecutionEngineException”的异常。
这句改成 public static extern int DC_Mif_Write([MarshalAs(UnmanagedType.LPArray)]int bAddr,ref string bData);
试试?我以前也也过,多年没接触这个东西了。
HANDLE void* System.IntPtr
BYTE unsigned char System.Byte
SHORT short System.Int16 WORD unsigned short System.UInt16
INT int System.Int32 UINT unsigned int System.UInt32 LONG long System.Int32 BOOL long System.Int32 DWORD unsigned long System.UInt32
ULONG unsigned long System.UInt32 CHAR char System.Char
LPSTR char* System.String 或 System.Text.StringBuilder
LPCSTR Const char* System.String 或 System.Text.StringBuilderLPWSTR wchar_t* System.String 或 System.Text.StringBuilderLPCWSTR Const wchar_t* System.String 或 System.Text.StringBuilder
FLOAT Float System.Single
DOUBLE Double System.Double
public static extern int DC_Mif_Write(UInt16 bAddr,ref byte[] bData);
加上这句就完美了[DllImport("FOX_DC.dll", EntryPoint = "DC_Mif_Read", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int DC_Mif_Read(UInt16 bAddr,ref byte[] bData);
StringBuilder 修改string看看
string udata1 =TextBox1.Text;
string udata2 = TextBox2.Text;
string udata3 =TextBox3.Text;
byte[] bdata1 = Encoding.Default.GetBytes(udata1);
byte[] bdata2 = Encoding.Default.GetBytes(udata2);
byte[] bdata3 = Encoding.Default.GetBytes(udata3);
write = ICCard.DC_Mif_Write(4, ref bdata1);
write = ICCard.DC_Mif_Write(5, ref bdata2);
write = ICCard.DC_Mif_Write(6, ref bdata3);
假如textbox1是两个汉字 那么 byte[] bdata1 是4维的
到调用 ICCard.DC_Mif_Write(4, ref bdata1);
此时 bdata1只有1维的
[DllImport("FOX_DC.dll", EntryPoint = "DC_Mif_Read", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int DC_Mif_Read(UInt16 bAddr,ref byte[] bData);我有下面调用
byte[] udata = new byte[255];
read = ICCard.DC_Mif_Read(4,ref udata);
引发类型为“System.ExecutionEngineException”的异常。
读卡器是向开发商买的,他们提供二次开发文档和dll
我们自己调用
LZ这次是C#搞PB
public static extern int DC_Mif_Read(int bAddr,ref string bData);
引发类型为“System.ExecutionEngineException”的异常。