title: Cannot set Scanner Capability because L_TwainStartCapsNeg returns error -84
body: <p>I'm trying to use the Leadtools API version 21 for automatically scanning some documents and here is a sudo code of what I have done (it runs in a secondary thread and the unlock has been done in the main thread):</p>
  <pre><code>void CheckRetCode(int rc)
  {
      if (SUCCESS != rc)
      {
          L_TCHAR errMsg[1024];
  
          memset(errMsg, 0, sizeof(errMsg));
          L_GetFriendlyErrorMessage(rc, errMsg, 1024, L_FALSE);
  
          throw TLeadException(errMsg, rc);
      }
  } 
  void OnThreadExecute(void)
  {
      HTWAINSESSION hSession = nullptr;
      APPLICATIONDATA appData;
      L_INT nRet;
      L_TCHAR pszTwnSourceName[1024];
      LTWAINSOURCE sInfo;
  
      memset(&amp;appData, 0, sizeof(APPLICATIONDATA));
      appData.uStructSize = sizeof(APPLICATIONDATA);
      appData.hWnd = hWnd;// hWnd is valid handle of my main window
      appData.uLanguage = TWLG_ENGLISH_USA;
      appData.uCountry = TWCY_USA;
      wcscpy(appData.szManufacturerName, L&quot;MyCompanyName&quot;);
      wcscpy(appData.szAppProductFamily, L&quot;MyProductName&quot;);
      wcscpy(appData.szAppName, appData.szAppProductFamily);
      wcscpy(appData.szVersionInfo, L&quot;Version 0.1.0.1&quot;);
      nRet = L_TwainInitSession2(&amp;hSession, &amp;appData, LTWAIN_INIT_MULTI_THREADED);
      CheckRetCode(nRet);// the exception gets catched elsewhere but no error reported here
      memset(pszTwnSourceName, 0, sizeof(pszTwnSourceName));
      wcscpy(pszTwnSourceName, L&quot;EPSON Artisan837/PX830&quot;); // the name of the scanner is verifyed
      sInfo.uStructSize = sizeof(LTWAINSOURCE);
      sInfo.pszTwainSourceName = pszTwnSourceName;
      CheckRetCode(L_TwainSelectSource(hSession, &amp;sInfo)); // No error reported here
      CheckRetCode(L_TwainStartCapsNeg(hSession)); // in here I get the return value -84 which is reported as &quot;TWAIN DS or DSM reported error, app shouldn't (no need for your app to report the error).&quot;
      // the rest of the code but we cannot get there since above code reports error
  }
  </code></pre>
  <p>Can anyone tell me what I'm doing wrong? Is there a step that I'm missing here?</p>
  <p><strong>Edit</strong><br />The function <code>L_TwainSelectSource()</code> make no effort to make sure the supplied source is valid and does not even return an error. As result, if you set the selected source to a garbage name, it will act as if it accepted it. From that point on if you try to Get/Set anything or try to acquire an image, every function returns <em>-84</em>.</p>
  <p>Thank you
  Sam</p>