title: Why does GetLastError() return different codes during debug vs "normal" execution?
body: <pre><code>try
  {      
  
      pConnect = sess-&gt;GetFtpConnection(ftpArgs.host, ftpArgs.userName, ftpArgs.password, port, FALSE );
  }
  catch (CInternetException* pEx) 
  {
      loginErrCode = GetLastError();
      printf("loginErrCode: %d\n", loginErrCode);
  
      if(loginErrCode == 12013)
      {
          printf("Incorrect user name!\n");
          exit(0);
      }
      else if(loginErrCode == 12014)
      {
          printf("Incorrect password!\n");
          exit(0);
      }
      else if(loginErrCode == 12007)
      {
          printf("Incorrect server name!\n");
          exit(0);
      }
      else //display all other errors
      {   
          TCHAR sz[1024];
          pEx-&gt;GetErrorMessage(sz, 1024);
          printf("ERROR!  %s\n, sz);
          pEx-&gt;Delete();
          exit(0);
      }  
  </code></pre>
  
  <p>When this code runs from visual studio with an intentional incorrect user name, GetLastError() returns 12014 (expected).  </p>
  
  <p>However, when running the same code from the command line (with the same exact incorrect username) GetLastError() returns 2?  (the <em>GetErrorMessage()</em> does return incorrect password)</p>
  
  <p>I do not understand what the difference is.  </p>
  
  <p>In addition, I ran the program from the command line while attaching the process to it in visual studio, to debug. I received 12014.   </p>
  
  <p>Whenever the debugger is involved, I get 12014. When I run the executable "normally" with the same parameters, I get 2.    </p>
  
  <p>Are the WinInet error codes not being found when I run the program outside of the debugger? Do I need to compile the program differently? </p>
  
  <p>Any help is appreciated. Thank You.</p>