我是新手to.net,我想确定是否使用winscard的SCardGetStatusChange检测到或删除了卡片。但它返回retcode = -2146435063,转换为Hex时会给我0x80100009 = SCARD_E_UNKNOWN_READER。我只是根据pinvoke.net
编写代码以下是我的代码示例
def find_area(r):
s = math.sqrt(2)
sidesquare = s * r * 2 / 2
square = (sidesquare * 2) ** 2
circle = 3.14 * r ** 2
area = circle - square
return area
以我的形式。
Public Structure SCARDREADER_STATE
Public szReader As String
Public pvUserData As IntPtr
Public dwCurrentState As Integer
Public dwEventState As Integer
Public cbAtr As Integer
Public rgbAtr() As Byte
End Structure
<DllImport(winscarddll, CharSet:=CharSet.Ansi, EntryPoint:="SCardGetStatusChangeA")>
Public Shared Function SCardGetStatusChange(ByVal hContext As IntPtr, ByVal dwTime As Integer, ByRef rgReaderState As SCARDREADER_STATE(), ByVal cReaders As Integer) As Integer
End Function
输出
t RET = -2146435063 读者:ACS ACR1222 3S PICC读卡器PICC 0 失败
答案 0 :(得分:0)
对于未来的研究人员/开发人员。
在SCardGetStatusChange中,我刚刚将SCardReaderState()更改为SCardReader
<DllImport(winscarddll, EntryPoint:="SCardGetStatusChangeA", CharSet:=CharSet.Ansi)>
Public Shared Function SCardGetStatusChange(ByVal hContext As IntPtr, ByVal dwTime As Integer, ByRef rgReaderState As SCARDREADER_STATE, ByVal cReaders As Integer) As Integer
End Function
然后在rgbAtr初始化中添加<MarshalAs(UnmanagedType.ByValArray, SizeConst:=36)>
。
希望这会有所帮助。