Оповещение приложения о произошедших событиях.
DWORD WINAPI ScanSCReadersThreadProc( LPVOID lpParameter )
{
	if( lpParameter == NULL )
		return 0;

	LP_SCREADERS_SCANER_PROC_PARAM	lpParam = (LP_SCREADERS_SCANER_PROC_PARAM)lpParameter;
	BOOL					bIsLoop	= TRUE;
	int					i;
	SCARDCONTEXT				hContext;
	if( SCardEstablishContext( SCARD_SCOPE_USER,NULL,NULL,&hContext ) !=  SCARD_S_SUCCESS )
		return 0;

	while( bIsLoop )
	{
		if( WaitForSingleObject( *lpParam->hExitEvent,0 ) == WAIT_OBJECT_0 )
		{
			bIsLoop = FALSE;

			SCardCancel( lpParam->hContext );

			for ( i = 0; i < (int)lpParam->dwReadersCount; i++ )
				delete (LPTSTR)lpParam->lpReaderState[i].szReader;
			delete []lpParam->lpReaderState;

			CloseHandle( *lpParam->hExitEvent );

			delete lpParam;
		}
		else
		{
			if( SCardGetStatusChange( hContext,INFINITE,lpParam->lpReaderState,lpParam->dwReadersCount ) == SCARD_S_SUCCESS )
			{
				for ( i = 0; i < (int)lpParam->dwReadersCount; i++ )
				{
					if( (lpParam->lpReaderState[i].dwEventState & SCARD_STATE_CHANGED) == SCARD_STATE_CHANGED )
					{
						if( (lpParam->lpReaderState[i].dwEventState & SCARD_STATE_EMPTY) == SCARD_STATE_EMPTY )
							::PostMessage( lpParam->hWnd,lpParam->nMessage,lpParam->wpCardTakeOutValue,i );
						else
							if( (lpParam->lpReaderState[i].dwEventState & SCARD_STATE_PRESENT) == SCARD_STATE_PRESENT )
								::PostMessage( lpParam->hWnd,lpParam->nMessage,lpParam->wpCardPutInValue,i );
					}

					lpParam->lpReaderState[i].dwCurrentState = lpParam->lpReaderState[i].dwEventState;
				}
			}
		}
	}

	return 0;
}