473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

WinScard.dll and VB2008

Hi,

I'm rewriting an old VB6 app of mine in VB2008. All has been going well with
calls to winscard.dll, until I needed to send an array of bytes as part of a
structure. When using a winscard trace, I can see that the bytes in the
array suddenly become nonsense, whereas I know that what I called the DLL
with was good.

I think I need to do something along the lines of MarshalAs, but I haven't
the first clue where to start. Any assistance would be greatly appreciated.
Snippets of code follow (the actual call causing trouble is on the
"lResult=" line).

Thanks

John

EMV_Fns.vb
==========

Public StructC3 As APDURec

..
..
..

Public Function Case3APDU(ByVal CLA As Int32, ByVal INS As Int32, ByVal
P1 As Int32, ByVal P2 As Int32, ByVal Lc As Int32, ByVal Data As String) As
ResponseStruct

Dim LoadByte As Integer

StructC3.bCLA = CLA
StructC3.bINS = INS
StructC3.bP1 = P1
StructC3.bP2 = P2
StructC3.bP3 = Lc
ReDim StructC3.Data(Lc - 1)

For LoadByte = 0 To (Len(Data) / 2) - 1
StructC3.Data(LoadByte) = Val("&H" + Mid(Data, 1 + (LoadByte *
2), 2))
Next LoadByte

SendBuffLen = &H5 + Lc
RcvBuffLen = &HFF

lResult = PCSC.SCardTransmit(hCard, 0, StructC3, SendBuffLen, 0,
ReceiveBuff(0), RcvBuffLen)

If lResult <SCARD_S_SUCCESS Then
DummyByte = PcscError("Case3-SCardTransmit", lResult)
End If

Case3APDU = ProcessResponse(ReceiveBuff, RcvBuffLen, True, 8, 16,
True)

End Function
PCSC_Fns.vb
===========

Public Structure APDURec
Dim bCLA As Byte
Dim bINS As Byte
Dim bP1 As Byte
Dim bP2 As Byte
Dim bP3 As Byte
Dim Data() As Byte
Dim IsSend As Boolean
End Structure

..
..
..

Declare Ansi Function SCardTransmit Lib "WinScard.dll" ( _
ByVal hCard As Int32, ByVal pioSendRequest As Int32, _
ByRef sendbuff As APDURec, ByVal SendBuffLen As Int32, _
ByVal pioRecvRequest As Int32, ByRef RecvBuff As Byte, _
ByRef RecvBuffLen As Int32) As Int32
Sep 13 '08 #1
2 5750

"John Whitworth" <se****@gEEEEEEEEEEEEEEEEmail.comwrote in message
news:Ol**************@TK2MSFTNGP03.phx.gbl...
Hi,

I'm rewriting an old VB6 app of mine in VB2008. All has been going well
with calls to winscard.dll, until I needed to send an array of bytes as
part of a structure. When using a winscard trace, I can see that the bytes
in the array suddenly become nonsense, whereas I know that what I called
the DLL with was good.
As suggested in an old message on another forum, I have tried using
System.Text.Stringbuilder for this, but it fails with an error saying that a
normal string might work. It doesn't! :-(

Thx

John

Sep 13 '08 #2

"John Whitworth" <se****@gEEEEEEEEEEEEEEEEmail.comwrote in message
news:Ol**************@TK2MSFTNGP03.phx.gbl...
Hi,

I'm rewriting an old VB6 app of mine in VB2008. All has been going well
with calls to winscard.dll, until I needed to send an array of bytes as
part of a structure. When using a winscard trace, I can see that the bytes
in the array suddenly become nonsense, whereas I know that what I called
the DLL with was good.
I think I've gone some way to solving this now. I've set up a new ByteStream
function, which just copies everything that was in an APDUrec structure into
a Byte() field. This then seems to pass into the DLL OK.

Thanks

John

Sep 13 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ray | last post by:
I am having a problem with issuing commands to my smartcard, I converted the call to SCardTransmit as follows: public static extern uint SCardTransmit( uint hCard, byte pioSendPci, ...
0
by: Chua Wen Ching | last post by:
Hi there, I had 2 questions. In SCardConnect function in Winscard.h: extern WINSCARDAPI LONG WINAPI SCardConnectA( IN SCARDCONTEXT hContext, IN LPCSTR szReader,
0
by: Ramazzotti... | last post by:
Hi All i am using Asp.net2.0, C#, VS2005 and i am using winscrsd.dll, ScardTransmit. i have this error no. = 2148532228 in return, so please i need your help. thank you in advance. this is the...
0
by: DavidL | last post by:
Error Code meaning in Winscard.dll functions? I am using the SCardTransmit function from winscard and getting errors back like: 0x00000006 0x0000054f 0x0000045d I can not find the...
7
by: Arthur Dent | last post by:
Does anyone know where i can find a decently thorough list of the language changes in VB2008, such as the new If() function? All i can seem to find through search engines, most of the articles...
2
by: Arthur Dent | last post by:
I am trying to make a VB2008 Express winforms project, and edit the form. However, when i try to open the form, i get this error: ..NET Framework 2.0 update not found. The win32manifest will not...
0
by: nieve | last post by:
Hello all, I'm working on a c# application using smart cards. I've been using vs2008 on an XP machine and everything was ok till I tried installing and running a demo on a vista machine. What...
6
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the...
0
by: John Dann | last post by:
Looking to migrate from VB2005 Pro to VB2008. Can anyone suggest/recommend a VB2008 book that highlights the changes from earlier versions of VB.Net (VB2003/2005) rather than describing VB2008...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.