How to Detect an ACS Reader Using C#

How do you detect an ACS reader in C#? Call SCardListReaders and keep the names that start with ACS; the model (for example ACR1252) and the interface word (PICC for contactless, SAM, or ICC for a contact slot) are in the same name. To notice readers being plugged in or removed while your program runs, call SCardGetStatusChange with one entry per reader plus the special reader name \\?PnP?\Notification: the call returns when a reader arrives, when a watched reader disappears, and when a card is placed or removed. No polling timer is needed.

This guide builds a .NET 10 watcher that does exactly that, and keeps working when the Smart Card service restarts. It uses the two shared files from PC/SC smart card programming in C#. It never connects to a card and sends no commands.

Which page do you need? For a one-off check that a reader is visible to PC/SC (service running, reader list, current state), use the PC/SC reader status check. To find out which ACS model you have from its label, Device Manager or hardware IDs, use identify your ACS reader model. This page is for your own program finding the right reader and reacting to changes.

PC/SC gives your program reader names, not USB IDs. The ACS driver builds each name from "ACS", the model family, an interface word and an index, for example ACS ACR1252 1S CL Reader PICC 0. The names ACS documents for each model are collected on identify your ACS reader model; the matching rules below are what your code needs.

You wantMatch in the nameWatch out for
Any ACS readerStarts with ACS Other readers on the same PC: a laptop's built-in reader, a Windows Hello or TPM virtual smart card. Do not assume reader 0 is yours.
A modelThe model token, e.g. ACR1252, ACR1552, ACR122U, ACR39UNames often drop the final U (ACR1252, ACR1552), and different driver versions have used different names for the same reader. Match the shortest stable part.
The contactless interfacePICCDual-interface readers such as the ACR1252U list a second entry for the SAM slot. Pick by name, never by index.
The SAM slotSAMOnly for SAM work; cards placed on the reader never appear here.
A contact card slot (ACR39U)ICC but not PICC"PICC" contains "ICC". Test for PICC first, as the code below does, or a contactless reader is taken for a contact one.
A second identical readerThe final index (0, 1 ...)The index depends on plug-in order. To tell two identical readers apart for good, use something you control, such as a setting chosen by the operator.

Two more cases to plan for. With the Windows built-in CCID driver instead of the ACS driver, the name can differ from the ACS documents, so check what your PCs actually list before you fix a pattern. And an ACR1552U set to keyboard-only output does not appear in PC/SC at all, so no code can find it (see the ACR1552U driver guide).

SCardGetStatusChange takes an array of SCARD_READERSTATE entries. In each one, dwCurrentState is what your program believes; the call blocks until the Smart Card service sees something different, then fills in dwEventState and sets SCARD_STATE_CHANGED on the entries that differ. The watcher builds its array like this:

EntrySet up asReturns when
0: \\?PnP?\NotificationName set, every other member zero (Microsoft's rule)A new reader is connected. pcsc-lite also signals reader removal through this entry; on Windows, the code relies on the reader's own entry for removal.
1..n: each readerName set, dwCurrentState = SCARD_STATE_UNAWARE (0) the first timeA card is placed (PRESENT) or removed (EMPTY), another program takes the card (INUSE, EXCLUSIVE), or the reader disappears (UNKNOWN or UNAVAILABLE).
  1. First call with a time-out of 0. Entries in the UNAWARE state make the call return at once with the current state of every reader. That is your starting snapshot.
  2. Acknowledge. Copy each dwEventState into dwCurrentState, without the CHANGED bit (PcscContext.Acknowledge). Skipping this step makes every later call return immediately, and the program spins at 100% CPU.
  3. Wait with INFINITE (or a finite time-out). When the call returns, compare old and new state for each entry marked CHANGED: not PRESENT before and PRESENT now is a card arrival; PRESENT before and EMPTY now is a removal; UNKNOWN or UNAVAILABLE means the reader left.
  4. If the reader set changed, list the readers again, report the difference, and rebuild the array. Carry over the known state of readers that are still there, so their cards are not reported twice; new readers start UNAWARE.
  5. Repeat until the user stops the program; Ctrl+C cancels the wait through SCardCancel, as explained in the threading and cancellation section of the tutorial.

Copying the whole dwEventState, upper bits included, matters for the PnP entry: pcsc-lite documents that the upper 16 bits of dwEventState carry an event counter. Microsoft does not document those bits, so the code never interprets them for readers; it only copies them back, which keeps the next wait from returning for a change it has already seen.

Language: C# 14 on .NET 10, Windows only (P/Invoke to winscard.dll). Prerequisites: a console project with WinScard.cs and Pcsc.cs from the C# tutorial (its setup steps take two minutes); replace Program.cs with the code below and run dotnet run. Any ACS reader with its driver installed; a reader is not needed to start the program.

Compiled by BSD; not yet tested on a reader. Built for net10.0 on 1 Dec 2026 with 0 warnings and 0 errors. BSD ran it on a Windows 11 PC with no ACS reader: it listed the PC's built-in virtual smart card reader as "not ACS", printed its state and kept waiting. Plugging in, unplugging and tapping cards on ACS readers is still to be tested.

// Day 36: detect ACS readers and watch them come and go. C# 14, .NET 10, Windows only.
// Needs WinScard.cs and Pcsc.cs in the same project. Compiled by BSD; not yet tested on a reader.
// Read-only: it never connects to a card and sends no commands.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using Bsd.Pcsc;

using var cts = new CancellationTokenSource();
Console.CancelKeyPress += (_, e) => { e.Cancel = true; cts.Cancel(); };

while (!cts.IsCancellationRequested)
{
    try
    {
        using var pcsc = new PcscContext();
        Watch(pcsc, cts.Token);              // returns only by exception
    }
    catch (OperationCanceledException) { break; }
    catch (PcscException ex) when (PcscErrors.ContextLost(ex.Code))
    {
        // The Smart Card service stopped or restarted: old handles are dead. Start again with a new context.
        Console.WriteLine($"{Now()} Smart Card service not available ({PcscErrors.Name(ex.Code)}). Retrying in 2 s.");
        if (cts.Token.WaitHandle.WaitOne(2000)) break;
    }
    catch (PcscException ex)
    {
        Console.WriteLine(ex.Message);
        return 1;
    }
}
Console.WriteLine("Stopped.");
return 0;

static void Watch(PcscContext pcsc, CancellationToken token)
{
    // 1. Snapshot: list the readers and classify the ACS ones.
    string[] readers = pcsc.ListReaders();
    Console.WriteLine($"{Now()} {readers.Length} PC/SC reader(s):");
    foreach (string r in readers) Console.WriteLine("   " + Classify(r));
    if (!readers.Any(r => Classify(r).IsAcs)) Console.WriteLine("   No ACS reader yet. Plug one in; this program keeps watching.");

    // 2. Watch: one entry per reader plus the special PnP entry, which reports reader arrival.
    var states = Build(readers, []);
    pcsc.WaitForChange(states, 0, token);   // all entries UNAWARE: returns at once with the current states
    foreach (var s in states.Skip(1)) Console.WriteLine($"   {s.szReader}: {PcscContext.Describe(s.dwEventState)}");
    PcscContext.Acknowledge(states);

    while (true)
    {
        pcsc.WaitForChange(states, WinScard.INFINITE, token);   // blocks until something changes, or Ctrl+C
        bool readerListChanged = (states[0].dwEventState & WinScard.SCARD_STATE_CHANGED) != 0;

        foreach (var s in states.Skip(1))
        {
            if ((s.dwEventState & WinScard.SCARD_STATE_CHANGED) == 0) continue;
            uint was = s.dwCurrentState, now = s.dwEventState;
            if ((now & (WinScard.SCARD_STATE_UNKNOWN | WinScard.SCARD_STATE_UNAVAILABLE)) != 0) readerListChanged = true;
            else if ((now & WinScard.SCARD_STATE_PRESENT) != 0 && (was & WinScard.SCARD_STATE_PRESENT) == 0)
                Console.WriteLine($"{Now()} Card placed on {s.szReader}  ATR {Apdu.HexSpaced(PcscContext.Atr(s))}");
            else if ((now & WinScard.SCARD_STATE_EMPTY) != 0 && (was & WinScard.SCARD_STATE_PRESENT) != 0)
                Console.WriteLine($"{Now()} Card removed from {s.szReader}");
            else
                Console.WriteLine($"{Now()} {s.szReader}: {PcscContext.Describe(now)}");
        }

        if (readerListChanged)
        {
            // 3. A reader arrived or left: list again and report the difference.
            string[] current = pcsc.ListReaders();
            foreach (string r in current.Except(readers)) Console.WriteLine($"{Now()} Reader connected: {Classify(r)}");
            foreach (string r in readers.Except(current)) Console.WriteLine($"{Now()} Reader removed: {r}");
            var old = states;
            readers = current;
            states = Build(readers, old);
            if (pcsc.WaitForChange(states, 0, token))   // new readers start UNAWARE, so this returns at once
                foreach (var s in states.Skip(1).Where(s => !old.Any(o => o.szReader == s.szReader)))
                    Console.WriteLine($"   {s.szReader}: {PcscContext.Describe(s.dwEventState)}");
        }
        PcscContext.Acknowledge(states);
    }
}

// Entry 0 is the PnP notification entry; entries 1..n are the readers.
// Readers that were already watched keep their last known state so no event is reported twice.
static WinScard.SCARD_READERSTATE[] Build(string[] readers, WinScard.SCARD_READERSTATE[] previous)
{
    var list = new List<WinScard.SCARD_READERSTATE>();
    var pnp = PcscContext.NewState(WinScard.PnpNotification);
    if (previous.Length > 0) pnp.dwCurrentState = pnp.dwEventState = previous[0].dwCurrentState;
    list.Add(pnp);
    foreach (string r in readers)
    {
        var s = PcscContext.NewState(r);
        foreach (var p in previous.Skip(1))
            if (p.szReader == r) s.dwCurrentState = s.dwEventState = p.dwCurrentState;
        list.Add(s);
    }
    return list.ToArray();
}

static ReaderInfo Classify(string name)
{
    // ACS reader names start with "ACS" and contain the model, e.g. "ACS ACR1252 1S CL Reader PICC 0".
    // The exact text depends on the driver, so match parts of it, never the whole string.
    bool isAcs = name.StartsWith("ACS ", StringComparison.OrdinalIgnoreCase);
    var m = Regex.Match(name, @"\bACR\d{2,4}[A-Z]?", RegexOptions.IgnoreCase);
    string model = m.Success ? m.Value.ToUpperInvariant() : "unknown model";
    string slot = name.Contains("PICC", StringComparison.OrdinalIgnoreCase) ? "contactless (PICC)"
        : name.Contains("SAM", StringComparison.OrdinalIgnoreCase) ? "SAM slot"
        : name.Contains("ICC", StringComparison.OrdinalIgnoreCase) ? "contact card slot (ICC)"
        : "interface not in name";
    return new ReaderInfo(name, isAcs, isAcs ? model : "not ACS", slot);
}

static string Now() => DateTime.Now.ToString("HH:mm:ss");

record ReaderInfo(string Name, bool IsAcs, string Model, string Slot)
{
    public override string ToString() => $"{Name}  [{Model}, {Slot}]";
}

Expected result: first a time-stamped count of readers, each with its model and interface in brackets, for example an ACR1252U as two lines, [ACR1252, contactless (PICC)] and [ACR1252, SAM slot], followed by each reader's current state. Then one line per event: Reader connected: ... when you plug a reader in, Reader removed: ... when you unplug it, Card placed on ... with the ATR, and Card removed from .... Ctrl+C prints Stopped.

If it fails: "No ACS reader yet" with an ACS reader plugged in means PC/SC does not list it: run the PC/SC status check and the Windows detection checks. A line "Smart Card service not available ... Retrying in 2 s" that repeats means the service is stopped or disabled. Any other message names the failing call and its code; see what to do for each error group.

A watcher runs for hours, so it will meet a stopped or restarted Smart Card service sooner or later: an administrator restarts it, a driver update restarts it, or the service is not running yet when your program starts. After that, the old context is useless and calls return SCARD_E_SERVICE_STOPPED, SCARD_E_NO_SERVICE or SCARD_E_INVALID_HANDLE.

The outer loop of the watcher handles this in one place: it catches those three codes (PcscErrors.ContextLost), disposes the context, waits two seconds (a wait that Ctrl+C can interrupt), establishes a new context and lists the readers again. Every other error ends the program with its message, because retrying would only hide a real problem. Microsoft sets the Smart Card service to start when a reader is connected, so an application started before any reader is plugged in should expect this path at first.

  • Run the watcher on its own thread with its own context, and hand events to the UI thread. Do not let a UI event handler call SCardGetStatusChange.
  • Store a choice, not a name. Save "ACR1252, PICC" in your settings rather than the full name with its index, and match it against the live list on start-up.
  • Debounce card events in the application if a card held at the edge of the field causes quick PRESENT/EMPTY pairs. Act on PRESENT, then ignore that reader until it reports EMPTY, as the UID reading loop does.
  • Remote Desktop changes the list: in a remote session the program sees the readers of the client computer. See readers in a Remote Desktop session.
  • Detection is not identification. The name tells you the model family, not the exact variant or firmware. If your code depends on firmware features, read the version once at start-up (firmware version guide).
  • A simpler alternative is to call SCardListReaders on a timer and compare lists. It works, but it reacts late, wakes the CPU for nothing and still needs SCardGetStatusChange for card events.
What you seeLikely causeWhat to do
The program uses 100% CPU and prints the same state over and overdwCurrentState not updated after each callAcknowledge after every return (copy event state to current state, minus CHANGED).
A newly plugged reader is not reportedNo \\?PnP?\Notification entry, or that entry was not zeroedAdd it as entry 0 with every other member zero, as PcscContext.NewState does.
The ACS reader is classed as "contact card slot"Testing for "ICC" before "PICC"Check PICC first.
An ACR1252U appears twiceIt has a PICC and a SAM interfaceExpected. Use the PICC entry for cards.
No ACS reader in the list, but Device Manager shows oneService stopped, reader not registered with PC/SC, keyboard-only mode, or a Remote Desktop sessionFollow the PC/SC status troubleshooting.
After unplugging, calls fail with 0x80100017 or 0x80100009Code still uses the old reader nameRebuild the state array from a fresh SCardListReaders.
"Retrying in 2 s" foreverSmart Card service disabledSee the Smart Card service settings.
Ctrl+C does not stop the programThe wait was not cancelledCancel through SCardCancel on the same context (the token in WaitForChange does this).

The behaviour of SCardGetStatusChange, the \\?PnP?\Notification entry and the state flags was checked in Microsoft's Win32 reference on 30 Nov 2026; the event counter and the reader-removal behaviour of the PnP entry in the pcsc-lite API documentation the same day. ACS reader-name patterns come from BSD's model identification guide, which cites ACS driver release notes and manuals.

BSD Infotech is an independent ACS supplier and integrator, not the manufacturer. ACS, the ACS logo and ACS product names belong to Advanced Card Systems Ltd.

Need reliable reader handling in your software?

Tell us your reader models, PCs and application. We build automatic reader selection and plug-and-play recovery in C#.