Smart Cards in .NET - A New Reference
(Page 4 of 5 )
And as you click the OK button a new reference is added to the project as shown below:

You may add a using or imports directive to include this namespace to your current files and use this class without really worrying about the details. The Interop generates the code such that the types available perfectly match the interface methods prototypes, which was the biggest hurdle in using P/Invoke.
I issued some commands using the buttons as in the image below. It responded well by returning the appropriate results. I’ve not written the whole business logic code for the application but just how the application would use this Interop generated class.
As soon as the Select Reader button is clicked the following code opens a reader selection Dialog. Once the user selects and clicks the Ok button it tries to open the reader.

private void BtnSelectAndOpenReader_Click
(object sender, System.EventArgs e)
{
try
{
m_strReaderName = Reader.SelectReader();
if(m_strReaderName.Length > 0)
{
if( Reader.OpenReader() == 0 )
{
m_bIsReaderOpen = true;
mcsStatusBar.Text = "Reader opened successfully";
string strRes;
int nResLen =Reader.SendCommand("00A4040007A0000000031010", 12,out strRes);
}
}
}
catch(System.Exception ex)
{
MessageBox.Show(this.Owner ,"An error has occured:nn" + ex.ToString()+ "nnError Message : " + ex.Message );
}
}
Next: The Code >>
More .NET Articles
More By Digvijay Chauhan