📄 winscard.pas
字号:
PSCARD_READERSTATE = PSCARD_READERSTATEA;
LPSCARD_READERSTATE = LPSCARD_READERSTATEA;
{$ENDIF}
{$EXTERNALSYM SCARD_READERSTATE}
{$EXTERNALSYM PSCARD_READERSTATE}
{$EXTERNALSYM LPSCARD_READERSTATE}
const
SCARD_STATE_UNAWARE = $0; // The application is unaware of the
{$EXTERNALSYM SCARD_STATE_UNAWARE} // current state, and would like to
// know. The use of this value
// results in an immediate return
// from state transition monitoring
// services. This is represented by
// all bits set to zero.
SCARD_STATE_IGNORE = $1; // The application requested that
{$EXTERNALSYM SCARD_STATE_IGNORE} // this reader be ignored. No other
// bits will be set.
SCARD_STATE_CHANGED = $2; // This implies that there is a
{$EXTERNALSYM SCARD_STATE_CHANGED} // difference between the state
// believed by the application, and
// the state known by the Service
// Manager. When this bit is set,
// the application may assume a
// significant state change has
// occurred on this reader.
SCARD_STATE_UNKNOWN = $4; // This implies that the given
{$EXTERNALSYM SCARD_STATE_UNKNOWN} // reader name is not recognized by
// the Service Manager. If this bit
// is set, then SCARD_STATE_CHANGED
// and SCARD_STATE_IGNORE will also
// be set.
SCARD_STATE_UNAVAILABLE = $8; // This implies that the actual
{$EXTERNALSYM SCARD_STATE_UNAVAILABLE} // state of this reader is not
// available. If this bit is set,
// then all the following bits are
// clear.
SCARD_STATE_EMPTY = $10; // This implies that there is not
{$EXTERNALSYM SCARD_STATE_EMPTY} // card in the reader. If this bit
// is set, all the following bits
// will be clear.
SCARD_STATE_PRESENT = $20; // This implies that there is a card
{$EXTERNALSYM SCARD_STATE_PRESENT} // in the reader.
SCARD_STATE_ATRMATCH = $40; // This implies that there is a card
{$EXTERNALSYM SCARD_STATE_ATRMATCH} // in the reader with an ATR
// matching one of the target cards.
// If this bit is set,
// SCARD_STATE_PRESENT will also be
// set. This bit is only returned
// on the SCardLocateCard() service.
SCARD_STATE_EXCLUSIVE = $80; // This implies that the card in the
{$EXTERNALSYM SCARD_STATE_EXCLUSIVE} // reader is allocated for exclusive
// use by another application. If
// this bit is set,
// SCARD_STATE_PRESENT will also be
// set.
SCARD_STATE_INUSE = $100; // This implies that the card in the
{$EXTERNALSYM SCARD_STATE_INUSE} // reader is in use by one or more
// other applications, but may be
// connected to in shared mode. If
// this bit is set,
// SCARD_STATE_PRESENT will also be
// set.
SCARD_STATE_MUTE = $200; // This implies that the card in the
{$EXTERNALSYM SCARD_STATE_MUTE} // reader is unresponsive or not
// supported by the reader or
// software.
SCARD_STATE_UNPOWERED = $400; // This implies that the card in the
{$EXTERNALSYM SCARD_STATE_UNPOWERED} // reader has not been powered up.
{$IFDEF WinSCard_DYNLINK}
type
TSCardLocateCardsA = function (hContext: LongInt; mszCards: LPStr; var rgReaderStates: PSCARD_READERSTATEA;
cReaders: LongInt): LongInt; stdcall;
TSCardLocateCardsW = function (hContext: LongInt; mszCards: LPWStr; var rgReaderStates: PSCARD_READERSTATEW;
cReaders: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardLocateCards = TSCardLocateCardsW;
{$ELSE}
TSCardLocateCards = TSCardLocateCardsA;
{$ENDIF}
{$ELSE}
function SCardLocateCardsA(hContext: LongInt; mszCards: LPStr; var rgReaderStates: PSCARD_READERSTATEA;
cReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardLocateCardsA}
function SCardLocateCardsW(hContext: LongInt; mszCards: LPWStr; var rgReaderStates: PSCARD_READERSTATEW;
cReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardLocateCardsW}
{$ENDIF}
type
PSCARD_ATRMASK = ^SCARD_ATRMASK;
{$EXTERNALSYM PSCARD_ATRMASK}
LPSCARD_ATRMASK = ^SCARD_ATRMASK;
{$EXTERNALSYM LPSCARD_ATRMASK}
SCARD_ATRMASK = record
cbArt: DWORD; // Number of bytes in the ATR and the mask.
rgbAtr: array[0..35] of Byte; // Atr of card (extra alignment bytes)
rgbMask: array[0..35] of Byte; // Mask for the Atr (extra alignment bytes)
end;
{$EXTERNALSYM SCARD_ATRMASK}
{$IFDEF WinSCard_DYNLINK}
type
TSCardLocateCardsByATRA = function (hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
var rgReaderStates: SCARD_READERSTATEA; cReaders: DWORD): LongInt; stdcall;
TSCardLocateCardsByATRW = function (hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
var rgReaderStates: SCARD_READERSTATEW; cReaders: DWORD): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardLocateCardsByATR = TSCardLocateCardsByATRW;
{$ELSE}
TSCardLocateCardsByATR = TSCardLocateCardsByATRA;
{$ENDIF}
TSCardGetStatusChangeA = function (hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEA;
cReaders: LongInt): LongInt; stdcall;
TSCardGetStatusChangeW = function (hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEW;
cReaders: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardGetStatusChange = TSCardGetStatusChangeW;
{$ELSE}
TSCardGetStatusChange = TSCardGetStatusChangeA;
{$ENDIF}
TSCardCancel = function (hContext: LongInt): LongInt; stdcall;
{$ELSE}
function SCardLocateCardsByATRA(hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
var rgReaderStates: SCARD_READERSTATEA; cReaders: DWORD): LongInt; stdcall;
{$EXTERNALSYM SCardLocateCardsByATRA}
function SCardLocateCardsByATRW(hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
var rgReaderStates: SCARD_READERSTATEW; cReaders: DWORD): LongInt; stdcall;
{$EXTERNALSYM SCardLocateCardsByATRW}
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
function SCardGetStatusChangeA( hContext: SCARDCONTEXT;
dwTimeout: LongInt;
var rgReaderStates: array of SCARD_READERSTATEA;
cReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardGetStatusChangeA}
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
function SCardGetStatusChangeW(hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEW;
cReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardGetStatusChangeW}
function SCardCancel (hContext: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardCancel}
{$ENDIF}
//
////////////////////////////////////////////////////////////////////////////////
//
// Card/Reader Communication Services
//
// The following services provide means for communication with the card.
//
const
SCARD_SHARE_EXCLUSIVE = 1; // This application is not willing to share this
{$EXTERNALSYM SCARD_SHARE_EXCLUSIVE} // card with other applications.
SCARD_SHARE_SHARED = 2; // This application is willing to share this
{$EXTERNALSYM SCARD_SHARE_SHARED} // card with other applications.
SCARD_SHARE_DIRECT = 3; // This application demands direct control of
{$EXTERNALSYM SCARD_SHARE_DIRECT} // the reader, so it is not available to other
// applications.
SCARD_LEAVE_CARD = 0; // Don't do anything special on close
{$EXTERNALSYM SCARD_LEAVE_CARD}
SCARD_RESET_CARD = 1; // Reset the card on close
{$EXTERNALSYM SCARD_RESET_CARD}
SCARD_UNPOWER_CARD = 2; // Power down the card on close
{$EXTERNALSYM SCARD_UNPOWER_CARD}
SCARD_EJECT_CARD = 3; // Eject the card on close
{$EXTERNALSYM SCARD_EJECT_CARD}
{$IFDEF WinSCard_DYNLINK}
type
TSCardConnectA = function (hContext: LongInt; szReader: LPStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
TSCardConnectW = function (hContext: LongInt; szReader: LPWStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardConnect = TSCardConnectW;
{$ELSE}
TSCardConnect = TSCardConnectA;
{$ENDIF}
TSCardReconnect = function (hCard: LongInt; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
dwInitialization: LongInt; var pdwActiveProtocol: LongInt): LongInt; stdcall;
TSCardDisconnect = function (hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
TSCardBeginTransaction = function (hCard: LongInt): LongInt; stdcall;
TSCardEndTransaction = function (hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
{$ELSE}
function SCardConnectA(hContext: LongInt; szReader: LPStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
{$EXTERNALSYM SCardConnectA}
function SCardConnectW(hContext: LongInt; szReader: LPWStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
{$EXTERNALSYM SCardConnectW}
function SCardReconnect(hCard: LongInt; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
dwInitialization: LongInt; var pdwActiveProtocol: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardReconnect}
function SCardDisconnect(hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardDisconnect}
function SCardBeginTransaction(hCard: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardBeginTransaction}
function SCardEndTransaction(hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardEndTransaction}
{$ENDIF}
//
// NOTE: This call corresponds to the PC/SC SCARDCOMM::Cancel routine,
// terminating a blocked SCardBeginTransaction service.
//
//
// NOTE: SCardState is an obsolete routine. PC/SC has replaced it with
// SCardStatus.
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardStatusA = function (hCard: LongInt; mszReaderNames: LPStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
TSCardStatusW = function (hCard: LongInt; mszReaderNames: LPWStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardStatus = TSCardStatusW;
{$ELSE}
TSCardStatus = TSCardStatusA;
{$ENDIF}
TSCardTransmit = function (hCard: LongInt; pioSendPci: Pointer; pbSendBuffer: PByte;
dwSendLength: DWORD; pioRecvPci: Pointer; pbRecvBuffer: PByte;
pcbRecvLength: PDWord): LongInt; stdcall;
{$ELSE}
function SCardStatusA(hCard: LongInt; mszReaderNames: LPStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardStatusA}
function SCardStatusW(hCard: LongInt; mszReaderNames: LPWStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardStatusW}
function SCardTransmit(hCard: LongInt; pioSendPci: Pointer; pbSendBuffer: PByte;
dwSendLength: DWORD; pioRecvPci: Pointer; pbRecvBuffer: PByte;
pcbRecvLength: PDWord): LongInt; stdcall;
{$EXTERNALSYM SCardTransmit}
{$ENDIF}
//
////////////////////////////////////////////////////////////////////////////////
//
// Reader Control Routines
//
// The following services provide for direct, low-level manipulation of the
// reader by the calling application allowing it control over the
// attributes of the communications with the card.
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardControl = function (hCard: LongInt; dwControlCode: LongInt; var pvInBuffer: PByte; cbInBufferSize: LongInt;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -