예제 #1
0
 private void bQuit_Click(object sender, EventArgs e)
 {
     // terminate the application
     retCode = ModWinsCard.SCardReleaseContext(hContext);
     retCode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
     System.Environment.Exit(0);
 }
예제 #2
0
        private int CardConnect(int connType)
        {
            //bool functionReturnValue = false;

            if (connActive)
            {
                retCode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
            }

            //Connect
            retCode = ModWinsCard.SCardConnect(hContext, cbReader.Text, ModWinsCard.SCARD_SHARE_SHARED, ModWinsCard.SCARD_PROTOCOL_T0 | ModWinsCard.SCARD_PROTOCOL_T1, ref hCard, ref Protocol);

            if (retCode != ModWinsCard.SCARD_S_SUCCESS)
            {
                if (connType != 1)
                {
                    displayOut(1, retCode, "");
                }
                connActive = false;
                return(retCode);
            }

            else
            {
                if (connType != 1)
                {
                    displayOut(0, 0, "Successful connection to " + cbReader.Text);
                }

                //functionReturnValue = retCode;
            }
            return(retCode);
        }
예제 #3
0
파일: Form1.cs 프로젝트: anbrousse1/projet
 private void btnExit_Click(object sender, System.EventArgs e)
 {
     //terminate the application
     retcode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
     retcode = ModWinsCard.SCardReleaseContext(hContext);
     Application.Exit();
 }
예제 #4
0
파일: Form1.cs 프로젝트: anbrousse1/projet
        private void btnDisconnect_Click(object sender, System.EventArgs e)
        {
            //Disconnect and unpower card
            if (connActive)
            {
                retcode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
            }

            retcode = ModWinsCard.SCardReleaseContext(hContext);

            connActive         = false;
            btnFormat.Enabled  = false;
            btnConnect.Enabled = false;
            btnReset.Enabled   = false;
            txtData.Enabled    = false;
            txtData.Text       = "";
            richTextBoxLogs.Clear();
            cbReader.Items.Clear();
            cbReader.Text      = "";
            GroupBox2.Enabled  = false;
            GBUserFile.Enabled = false;
            RBAA11.Checked     = false;
            RBBB22.Checked     = false;
            RBCC33.Checked     = false;
        }
예제 #5
0
        public void CardReset()
        {
            if (connActive)
            {
                retCode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
            }

            retCode = ModWinsCard.SCardReleaseContext(hCard);
        }
예제 #6
0
        private void bReset_Click(object sender, EventArgs e)
        {
            if (connActive)
            {
                retCode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
            }

            retCode = ModWinsCard.SCardReleaseContext(hCard);
            InitMenu();
        }
예제 #7
0
파일: Form1.cs 프로젝트: anbrousse1/projet
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            // Connect to selected reader using hContext handle and obtain hCard handle
            if (connActive)
            {
                retcode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
            }

            // Connect to the reader using hContext handle and obtain hCard handle
            retcode = ModWinsCard.SCardConnect(hContext, cbReader.Text, ModWinsCard.SCARD_SHARE_EXCLUSIVE, 0 | 1, ref hCard, ref ActiveProtocol);
            if (retcode != ModWinsCard.SCARD_S_SUCCESS)
            {
                displayOut(1, retcode, "");
                return;
            }
            else
            {
                displayOut(0, 0, "Connection OK");
                connActive = true;
            }

            btnFormat.Enabled = true;
            RBAA11.Checked    = true;
        }
예제 #8
0
        private void Connect()
        {
            if (IsConnected)
            {
                _returnCode = ModWinsCard.SCardDisconnect(_hCard, ModWinsCard.SCARD_EJECT_CARD);

                IsConnected = false;
            }

            //_returnCode = APDUCommands.SetPICCParams(_piccParams);
            _returnCode = ModWinsCard.SCardConnect(_hContext, _name, ModWinsCard.SCARD_SHARE_SHARED, ModWinsCard.SCARD_PROTOCOL_T0 | ModWinsCard.SCARD_PROTOCOL_T1, ref _hCard, ref _protocol);

            if (_returnCode != ModWinsCard.SCARD_S_SUCCESS)
            {
                _returnCode = ModWinsCard.SCardConnect(_hContext, _name, ModWinsCard.SCARD_SHARE_DIRECT, ModWinsCard.SCARD_PROTOCOL_UNDEFINED, ref _hCard, ref _protocol);

                if (_returnCode != ModWinsCard.SCARD_S_SUCCESS)
                {
                    throw new ApplicationException(@"Failed to connect to reader " + _name, new ApplicationException(ModWinsCard.GetScardErrMsg(_returnCode)));
                }
            }

            IsConnected = true;
        }
예제 #9
0
 private void frmStart_FormClosing(object sender, FormClosingEventArgs e)
 {
     retCode = ModWinsCard.SCardReleaseContext(hContext);
     retCode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
     System.Environment.Exit(0);
 }
 private static void EndTransaction()
 {
     ModWinsCard.SCardEndTransaction(hCard, ModWinsCard.SCARD_LEAVE_CARD);
     ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD);
     ModWinsCard.SCardReleaseContext(hContext);
 }
예제 #11
0
 public void Dispose()
 {
     ModWinsCard.SCardEndTransaction(_hCard, ModWinsCard.SCARD_EJECT_CARD);
     ModWinsCard.SCardReleaseContext(_hContext);
     ModWinsCard.SCardDisconnect(_hCard, ModWinsCard.SCARD_EJECT_CARD);
 }