Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 186165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:35:56+00:00 2026-05-11T15:35:56+00:00

Why might SCardEstablishContext hang, never to return, when called from a service? I have

  • 0

Why might SCardEstablishContext hang, never to return, when called from a service?

I have code that works fine on lots of Windows installations. It accesses a Cherry keyboard’s Smart Card reader (6×44) to read data on a smart card. It works fine on most PCs it has been tried on. However, on some PCs, running in Spain with Spanish Windows, the SCardEstablishContext function never returns. I cannot work out why this might be. I have logging either side of it, but the log entry after it does not appear. I cannot then shut it down (the worker thread is getting stuck), and have to kill it.

Exactly the same thread code works fine if run from an application, and not a service. Giving the service login settings of a user instead of system makes no difference. I’ve installed Spanish XP on a machine here, but it works just fine. The far end has the same Winscard.dll version as I have here (both at XP SP3 status). No errors are shown in the event log.

How might I work out what is going wrong, and what might be fixing it? (Delphi code below)

// based on code by Norbert Huettisch function TPCSCConnector.Init: boolean; var     RetVar: LongInt;     ReaderList: string;     ReaderListSize: integer;     v: array[0..MAXIMUM_SMARTCARD_READERS] of string;     i: integer; begin     Result := false;     FNumReaders := 0; {$IFDEF MJ_ONLY}     LogReport(leInformation, 'About to call SCardEstablishContext'); {$ENDIF}     RetVar := SCardEstablishContext(SCARD_SCOPE_USER, nil, nil, @FContext); {$IFDEF MJ_ONLY}     // never gets to report this (and logging known good etc)     LogReport(leInformation, 'SCardEstablishContext result = ' + IntToStr(RetVar)); {$ENDIF}     if RetVar = SCARD_S_SUCCESS then     begin 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:35:57+00:00Added an answer on May 11, 2026 at 3:35 pm

    There may be different reasons why the API function appears to hang, like a deadlock, or an invisible message box or dialog waiting for user input. You should try to get a stacktrace using WinDbg.

    You should also make sure that you are trying to reproduce the bug in the same environment. Important points might be whether Fast User Switching is active and whether other users are logged on, also that there are the same device drivers and services running.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You might have a set of properties that is used on the developer machine,
This might be an interesting question. I need to test that if I can
Might be just me, but I have a hard time understanding how to secure
Might be subjective and/or discussion.. but here goes. I've been asked to estimate a
This might seem like a stupid question I admit. But I'm in a small
I might be missing something really obvious. I'm trying to write a custom Panel
This might be on the discussy side, but I would really like to hear
This might be a bit on the silly side of things but I need
This might seem obvious but I've had this error when trying to use LINQ
This might sound like a little bit of a crazy question, but how can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.