⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icdemo.cpp

📁 IC卡操作Demo 包括了常见的IC卡种类。可执行写入、读出、校验、密码修改、批量作业等功能。
💻 CPP
字号:
// IcDemo.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "IcDemo.h"
#include "IcDemoDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CIcDemoApp

BEGIN_MESSAGE_MAP(CIcDemoApp, CWinApp)
	//{{AFX_MSG_MAP(CIcDemoApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CIcDemoApp construction

CIcDemoApp::CIcDemoApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CIcDemoApp object

CIcDemoApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CIcDemoApp initialization

BOOL CIcDemoApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
    hsureDll=LoadLibrary("sure32wc.dll");
	if(hsureDll!=NULL)
	{
		sureinit_com=(INITCOM)GetProcAddress(hsureDll,"init_com");
		suresele_card=(SELECTTYPE)GetProcAddress(hsureDll,"sele_card");
		surepower_on=(POWERON)GetProcAddress(hsureDll,"power_on");
		surepower_off=(POWEROFF)GetProcAddress(hsureDll,"power_off");
		surerd_asc=(RDHEX)GetProcAddress(hsureDll,"rd_asc");
		surerd_str=(RDASC)GetProcAddress(hsureDll,"rd_str");
        surewr_asc=(WRHEX)GetProcAddress(hsureDll,"wr_asc");
		surewr_str=(WRASC)GetProcAddress(hsureDll,"wr_str");
        surewr_sc=(WRPWD)GetProcAddress(hsureDll,"wr_sc");
		surerd_sm=(RDPWD)GetProcAddress(hsureDll,"rd_sm");
		surechk_sc=(CHKPWD)GetProcAddress(hsureDll,"chk_sc");
        sureclose_com=(CLOSECOM)GetProcAddress(hsureDll,"close_com");
	}
	else
		MessageBox(NULL,"找不到sure32wc.dll动态连接库","信息提示",MB_OK|MB_ICONSTOP);
	intPage=1;
	CIcDemoDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

CString CIcDemoApp::ReadWriteError(int nError)
{
   CString str;
   switch (nError)
   {	  
      case 2:
        str = "请插入智能卡";
        break;
	  case 3:
        str = "卡未上电";
		break;
      case 4:
       // str = "串口错误";
		str = "卡未上电";
        break;
      case 9:
        str = "数据长度错误";
		break;
      case 10:
        str = "卡数据异常";
		break;
      case 11:
        str = "密码检验错误";
		break;
      case 14:
        str = "智能卡已损坏";
		break;
      case 16:
        str = "智能卡卡型错误";
		break;
      default:
        str = "读写卡错误";

   }
   MessageBox(NULL,str,"信息提示",MB_OK|MB_ICONSTOP);
   return str;
}

int CIcDemoApp::ExitInstance() 
{
	// TODO: Add your specialized code here and/or call the base class
	if(hsureDll!=NULL)
	{
        sureclose_com();
		FreeLibrary(hsureDll);
	}
	return CWinApp::ExitInstance();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -