title: Why WNetAddConnection2 still returns 1219 after successfully calling WNetCancelConnection2?
body: <p>I wrote some code to connect with some share on a remote server. If <code>WNetAddConnection2</code> returns <code>ERROR_SESSION_CREDENTIAL_CONFLICT</code> (1219), I will first cancel the connection by <code>WNetCancelConnection2</code> (return NO_ERROR). And then reconnect. But <code>WNetAddConnection2</code> still returns <code>1219</code>. 
  Why this and how to fix it?</p>
  
  <p>Here's my code</p>
  
  <pre><code>BOOL ADDirectorySearch::IPCConnect(CString strServerName, CString strDomainName, CString strUserName, CString strPassWord)
  {
      CString strServerNameWithSlash = _T("\\\\") + strServerName; //actually is \\klbnt
      CString strFullUserName = strDomainName + _T("\\") + strUserName; //is domaintest\administrator
      _bstr_t bstrServerNameWithSlash = strServerNameWithSlash;
      _bstr_t bstrFullUserName = strFullUserName;
      _bstr_t bstrPassWord = strPassWord;
      DWORD dwResult;
      NETRESOURCEW netResource;
      memset(&amp;netResource, 0, sizeof(netResource));
      netResource.dwScope = RESOURCE_GLOBALNET;  
      netResource.dwType = RESOURCETYPE_DISK;
      netResource.dwDisplayType = RESOURCEDISPLAYTYPE_GENERIC;  
      netResource.dwUsage = RESOURCEUSAGE_CONNECTABLE;
      netResource.lpProvider = L"";
      netResource.lpRemoteName = bstrServerNameWithSlash;//Remote IP like:\\192.168.1.11
      dwResult = WNetAddConnection2W(&amp;netResource, bstrPassWord, bstrFullUserName, CONNECT_INTERACTIVE);
      if (dwResult == ERROR_SESSION_CREDENTIAL_CONFLICT)
      {
          dwResult = WNetCancelConnection2W(bstrServerNameWithSlash, CONNECT_UPDATE_PROFILE, TRUE);
          if (dwResult == NO_ERROR)
          {
              dwResult = WNetAddConnection2W(&amp;netResource, bstrPassWord, bstrFullUserName, CONNECT_INTERACTIVE);
          }
          else
          {
              //MyMessageBox_Error(_T("IPCConnect Error."), _T("Error"));
              return FALSE;
          }
      }
      if (dwResult == NO_ERROR)
      {
          return TRUE;
      }
      else
      {
          //MyMessageBox_Error(_T("IPCConnect Error."), _T("Error"));
          return FALSE;
      }
  }
  </code></pre>
  
  <p>FYI: After typing "net use" in cmd, I got this, I feel there's something with error:</p>
  
  <pre><code>Status       Local     Remote                    Network
  
  -------------------------------------------------------------------------------
  OK                     \\klbnt\NRDC1001          Microsoft Windows Network
  The command completed successfully.
  </code></pre>