G
Guest
Hi everyone
Just a quick question! Everytime i run the SCardConnect Command
SCARD_E_INVALID_PARAMETER is returned and i have absolutely no idea why!
I have a VB6 program that works perfectly, but when i try and implement the
same in VB.NET, I get the SCARD_E_INVALID_PARAMETER error.
I was just wondering if anyone could help? when i debug the program
hContext in VB6 = 0 however in VB.NET it = -855572479 or -855572480. Which
then produces a return code of HEX - 80100004 (SCARD_E_INVALID_PARAMETER)
The code i am using is:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim defaultReader As String
defaultReader = ComboBox1.Text
Protocol = clsPCSC.GetProtocol
ReturnCode = clsPCSC.winSCard.SCardConnect _
( _
hContext, _
defaultReader, _
clsPCSC.SCARD_SHARE_EXCLUSIVE, _
clsPCSC.SCARD_PROTOCOL_T0, _
hCard, _
Protocol _
)
If ReturnCode <> clsPCSC.SCARD_S_SUCCESS Then
MessageBox.Show( _
"An Error Occurred when connecting to the smarcard" _
& ControlChars.CrLf & "Error Number: " & Hex(ReturnCode), _
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning, _
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly)
Else
List1.Items.Add("Connection OK")
End If
End Sub
HOPEFULLY someone can help
Thanks in advance,
Just a quick question! Everytime i run the SCardConnect Command
SCARD_E_INVALID_PARAMETER is returned and i have absolutely no idea why!
I have a VB6 program that works perfectly, but when i try and implement the
same in VB.NET, I get the SCARD_E_INVALID_PARAMETER error.
I was just wondering if anyone could help? when i debug the program
hContext in VB6 = 0 however in VB.NET it = -855572479 or -855572480. Which
then produces a return code of HEX - 80100004 (SCARD_E_INVALID_PARAMETER)
The code i am using is:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim defaultReader As String
defaultReader = ComboBox1.Text
Protocol = clsPCSC.GetProtocol
ReturnCode = clsPCSC.winSCard.SCardConnect _
( _
hContext, _
defaultReader, _
clsPCSC.SCARD_SHARE_EXCLUSIVE, _
clsPCSC.SCARD_PROTOCOL_T0, _
hCard, _
Protocol _
)
If ReturnCode <> clsPCSC.SCARD_S_SUCCESS Then
MessageBox.Show( _
"An Error Occurred when connecting to the smarcard" _
& ControlChars.CrLf & "Error Number: " & Hex(ReturnCode), _
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning, _
MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly)
Else
List1.Items.Add("Connection OK")
End If
End Sub
HOPEFULLY someone can help
Thanks in advance,