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 587753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:14:46+00:00 2026-05-13T15:14:46+00:00

try { pConnect = sess->GetFtpConnection(ftpArgs.host, ftpArgs.userName, ftpArgs.password, port, FALSE ); } catch (CInternetException* pEx)

  • 0
try
{      

    pConnect = sess->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->GetErrorMessage(sz, 1024);
        printf("ERROR!  %s\n, sz);
        pEx->Delete();
        exit(0);
    }  

When this code runs from visual studio with an intentional incorrect user name, GetLastError() returns 12014 (expected).

However, when running the same code from the command line (with the same exact incorrect username) GetLastError() returns 2? (the GetErrorMessage() does return incorrect password)

I do not understand what the difference is.

In addition, I ran the program from the command line while attaching the process to it in visual studio, to debug. I received 12014.

Whenever the debugger is involved, I get 12014. When I run the executable “normally” with the same parameters, I get 2.

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?

Any help is appreciated. Thank You.

  • 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. Editorial Team
    Editorial Team
    2026-05-13T15:14:46+00:00Added an answer on May 13, 2026 at 3:14 pm

    My memory is a little hazy in this regard, but what happens if you use the m_dwError field of the CInternetException object instead of calling GetLastError()?

    My guess is that something is causing the error code to be reset between when the actual error and your call to GetLastError(). I don’t know why this happens when running outside the debugger but not inside the debugger. However, MFC caches the error code that caused the exception in the thrown object, so you should be able to use the cached value regardless of what API calls have happened since the exception was thrown.

    GetErrorMessage() returns the correct error string because it uses this m_dwError field, rather than calling GetLastError().

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

Sidebar

Ask A Question

Stats

  • Questions 356k
  • Answers 356k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just put all those exceptional cases into the character class.… May 14, 2026 at 8:57 am
  • Editorial Team
    Editorial Team added an answer Furthermore, in C99 the behaviour is defined to be the… May 14, 2026 at 8:57 am
  • Editorial Team
    Editorial Team added an answer "Each time, the call is very similar, but with slight… May 14, 2026 at 8:57 am

Related Questions

Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
try { ... } catch (SQLException sqle) { String theError = (sqle).getSQLState(); ... }
Try Dim ds As DataSet = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings(connstr).ConnectionString, CommandType.StoredProcedure, Get_All, New SqlParameter(@userid, Session(userid))) rptBundles.DataSource =
Try the following simple example: <html> <head> <style> div, input { border: 1px solid
Try recording a macro in Word 2007, notice you can't do a thing to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.