bit
bit

Reputation: 973

casmcard wrapper

I've got a smartcard together a simple sdk written in C++ (casmcard.dll).

I need to call some method in above dll through managed code (C#) specially to read and write some particular block or sector.

No casmcard.dll wrapper found.

Any ideas?

Upvotes: 0

Views: 527

Answers (1)

Simon Halsey
Simon Halsey

Reputation: 5480

Sounds like you need to dig into interop. If it's a COM object, you can import it & have .net create the wrapper for you. If it's old school dll functions, then you just need to import them.

Interop is a bit of a black art, so you'll need to google around on mapping & marshalling types.

Edit

So your function looks like?

CasCLGetSN( IN SCARDHANDLE hCard, OUT LPBYTE pbCSNBuffer, IN DWORD cbCSNBufferSize, OUT LPDWORD pcbCSNLength )

Try this:

CasCLGetSN(ScardHandle hCard, out IntPtr pbCSNBuffer, UInt32 cbCSNBufferSize, out UInt32 pcbCSNLength)

You'll then need to use the overloaded Marshal.Copy() to get the contents of the pbCSNBuffer. Also check what the definition of scardHandle is. If it's a struct, then declare it & add the Sequential attribute to it.

Upvotes: 1

Related Questions