<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CInternetException, try und catch]]></title><description><![CDATA[<p>Warum wird mir die Exception bei einem falschen Passwort nicht ausgeworfen?<br />
Ich verstehe es beim besten willen momentan nicht.</p>
<pre><code class="language-cpp">CString strHeaders = _T(&quot;Content-Type: content=text/html; charset=windows-1252&quot;); 

CString strFormData = _T(r_connect);

CInternetSession session; 

CString error;
CHttpConnection* pConnection;

try
{
  pConnection = session.GetHttpConnection(_T(r_ip),(INTERNET_PORT)80,r_user,r_password); 
}
catch (CInternetException *pIE) 
     { 
error = getInetError(pIE-&gt;m_dwError);
MessageBox(error);

     }

//...
//...

CString CTest::getInetError(DWORD err)
    {
     HANDLE h = ::GetModuleHandle(_T(&quot;WinINet.dll&quot;));
     if(h != NULL)
	{ /* got module */
	 LPTSTR p;
	 if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
			    FORMAT_MESSAGE_FROM_HMODULE,
			    (LPCVOID)h,
			    err,
			    0, // default language
			    (LPTSTR)&amp;p,
			    0,
			    NULL) != 0)
	    { /* format succeeded */
	     CString s(p);
	     s.Replace(_T(&quot;\r\n&quot;), _T(&quot;&quot;));
	     return s;
	    } /* format succeeded */
	} /* got module */

     CString s;
     s.Format(_T(&quot;%d&quot;), err);
     return s;
    } // getInetError
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/201777/cinternetexception-try-und-catch</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 23:55:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/201777.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Jan 2008 23:07:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CInternetException, try und catch on Thu, 03 Jan 2008 23:08:06 GMT]]></title><description><![CDATA[<p>Warum wird mir die Exception bei einem falschen Passwort nicht ausgeworfen?<br />
Ich verstehe es beim besten willen momentan nicht.</p>
<pre><code class="language-cpp">CString strHeaders = _T(&quot;Content-Type: content=text/html; charset=windows-1252&quot;); 

CString strFormData = _T(r_connect);

CInternetSession session; 

CString error;
CHttpConnection* pConnection;

try
{
  pConnection = session.GetHttpConnection(_T(r_ip),(INTERNET_PORT)80,r_user,r_password); 
}
catch (CInternetException *pIE) 
     { 
error = getInetError(pIE-&gt;m_dwError);
MessageBox(error);

     }

//...
//...

CString CTest::getInetError(DWORD err)
    {
     HANDLE h = ::GetModuleHandle(_T(&quot;WinINet.dll&quot;));
     if(h != NULL)
	{ /* got module */
	 LPTSTR p;
	 if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
			    FORMAT_MESSAGE_FROM_HMODULE,
			    (LPCVOID)h,
			    err,
			    0, // default language
			    (LPTSTR)&amp;p,
			    0,
			    NULL) != 0)
	    { /* format succeeded */
	     CString s(p);
	     s.Replace(_T(&quot;\r\n&quot;), _T(&quot;&quot;));
	     return s;
	    } /* format succeeded */
	} /* got module */

     CString s;
     s.Format(_T(&quot;%d&quot;), err);
     return s;
    } // getInetError
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1430334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1430334</guid><dc:creator><![CDATA[Shell32]]></dc:creator><pubDate>Thu, 03 Jan 2008 23:08:06 GMT</pubDate></item><item><title><![CDATA[Reply to CInternetException, try und catch on Fri, 04 Jan 2008 07:54:36 GMT]]></title><description><![CDATA[<p>Kann es sein, dass die Exception erst beim OpenRequest reworfen wird?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1430397</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1430397</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 04 Jan 2008 07:54:36 GMT</pubDate></item><item><title><![CDATA[Reply to CInternetException, try und catch on Fri, 04 Jan 2008 08:39:27 GMT]]></title><description><![CDATA[<p>Hallo Martin,</p>
<p>das habe ich auch schon versucht. Hier erhalte ich auch die Info, wenn<br />
die IP falsch ist. Allerdings gibt es nichts zurück bei falschem User<br />
oder Passwort! Zudem habe ich plötzlich das Problem, dass ich in einer<br />
MessageBox die Fehlerbeschreibung erhalte, obwohl SetErrorMode gesetzt<br />
ist und ich die Meldungen selbst behandeln will (Anzeige in IDC_EDIT2).</p>
<p>Es soll ja auch laut MSDN das Verbinden als solches eine Exception<br />
zurückgeben können:</p>
<blockquote>
<p>CInternetSession::GetHttpConnection</p>
<p>Return Value<br />
A pointer to a CHttpConnection object. If the call fails, determine the cause of the failure by examining the thrown CInternetException object.</p>
</blockquote>
<pre><code class="language-cpp">CString s =&quot;&quot;;

SetErrorMode(SEM_FAILCRITICALERRORS);

CString r_ip = konfigdaten(&quot;Router-IP&quot;);
CString r_connect = konfigdaten(&quot;Connect&quot;);
CString r_disconnect = konfigdaten(&quot;Disconnect&quot;);
CString r_user = konfigdaten(&quot;User&quot;);
CString r_password = konfigdaten(&quot;Password&quot;);

CString strHeaders = _T(&quot;Content-Type: content=text/html; charset=windows-1252&quot;); 

CString strFormData = _T(r_connect);

CInternetSession session; 

CHttpConnection* pConnection;

try
{
pConnection = session.GetHttpConnection(_T(r_ip),(INTERNET_PORT)80,_T(r_user),_T(r_password)); 
 }
catch (CInternetException *pIEx)
{
 s = getInetError(pIE-&gt;m_dwError);
 GetDlgItem(IDC_EDIT2)-&gt;SetWindowText(s);
}

CHttpFile* pFile;

try 
{
  pFile = pConnection-&gt;OpenRequest(CHttpConnection::HTTP_VERB_POST, _T(&quot;&quot;));
}
  catch (CInternetException *pIE)
  {
	  s = getInetError(pIE-&gt;m_dwError);
	  GetDlgItem(IDC_EDIT2)-&gt;SetWindowText(s);
  }

bool result = pFile-&gt;SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1430409</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1430409</guid><dc:creator><![CDATA[Shell32off]]></dc:creator><pubDate>Fri, 04 Jan 2008 08:39:27 GMT</pubDate></item><item><title><![CDATA[Reply to CInternetException, try und catch on Fri, 04 Jan 2008 12:43:51 GMT]]></title><description><![CDATA[<p>Hat niemand eine Idee was man noch versuchen könnte um die Fehler<br />
selbst anzeigen lassen zu können und zu prüfen, ob user/password<br />
richtig sind? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1430577</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1430577</guid><dc:creator><![CDATA[Shell32offline]]></dc:creator><pubDate>Fri, 04 Jan 2008 12:43:51 GMT</pubDate></item><item><title><![CDATA[Reply to CInternetException, try und catch on Fri, 04 Jan 2008 22:44:11 GMT]]></title><description><![CDATA[<p>Es gibt vermutlich keinen Weg zu prüfen ob GetHttpConnection<br />
erfolgreich war! Die einzige Chance ist SendRequest auszuwerten.<br />
Und da wird nur geprüft ob der Link abgesetzt werden konnte.<br />
Das wird in der Regel auch successfull sein. Man steht dann allerdings<br />
theoretisch vor dem Loginscreen, wenn Benutzer und Kennwort falsch waren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    />.</p>
<p>Damit ist der Rückgabewert also auch wieder unbrauchbar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
<p>Wenn sich hier jemand findet der das wiederlegen kann, dann bitte...<br />
Aber es wird ganz einfach unmöglich sein zu prüfen ob alle Aufrufe erfolgreich<br />
waren!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1430844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1430844</guid><dc:creator><![CDATA[Vermutung]]></dc:creator><pubDate>Fri, 04 Jan 2008 22:44:11 GMT</pubDate></item><item><title><![CDATA[Reply to CInternetException, try und catch on Mon, 07 Jan 2008 07:27:11 GMT]]></title><description><![CDATA[<p>Vermutung schrieb:</p>
<blockquote>
<p>Es gibt vermutlich keinen Weg zu prüfen ob GetHttpConnection<br />
erfolgreich war! Die einzige Chance ist SendRequest auszuwerten.<br />
Und da wird nur geprüft ob der Link abgesetzt werden konnte.<br />
Das wird in der Regel auch successfull sein. Man steht dann allerdings<br />
theoretisch vor dem Loginscreen, wenn Benutzer und Kennwort falsch waren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    />.</p>
<p>Damit ist der Rückgabewert also auch wieder unbrauchbar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
<p>Wenn sich hier jemand findet der das wiederlegen kann, dann bitte...<br />
Aber es wird ganz einfach unmöglich sein zu prüfen ob alle Aufrufe erfolgreich<br />
waren!!!</p>
</blockquote>
<p>Ich befürchte ja fast, dass du da recht hast <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /><br />
Aber was soll das? Hat es sicherheitstechnische Hintergründe?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1432210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1432210</guid><dc:creator><![CDATA[Shell32offline]]></dc:creator><pubDate>Mon, 07 Jan 2008 07:27:11 GMT</pubDate></item></channel></rss>