<?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[Laufzeitfehler bei Code | WinInet | File aus dem Web saugen]]></title><description><![CDATA[<p>hallo,</p>
<p>ich versuche gerade ein programm zu schreiben welches über die WinInet-Lib<br />
eine Datei aus dem Internet herunterläd.</p>
<p>Das herunterladen kappt anscheinend auch perfekt die Datei ist lokal<br />
vollständig vorhanden!</p>
<p>aber danach kommt ein Laufzeitfehler ?!</p>
<p>hier mein code:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;iostream&gt;
#include &lt;WinINet.h&gt;

using namespace std;

#pragma comment( lib, &quot;WinINet.lib&quot; )

BOOL GetFile (HINTERNET IN hOpen,CHAR *szUrl,CHAR *szFileName)
{
	DWORD dwSize;
	CHAR szHead[] = &quot;Accept: */*\r\n\r\n&quot;;
	VOID* szTemp[25];
	HINTERNET hConnect;
	FILE* pFile;
	int size_v=0;

	if (!(hConnect=InternetOpenUrl(hOpen,szUrl,szHead,lstrlen(szHead),INTERNET_FLAG_DONT_CACHE,0)))
	{
		cerr &lt;&lt; &quot;Error 1!&quot; &lt;&lt; endl;
		return 0;
	}

	if  ( !(pFile = fopen (szFileName, &quot;wb&quot; ) ) )
	{
		cerr &lt;&lt; &quot;Error 2!&quot; &lt;&lt; endl;
		return FALSE;
	}
	do
	{
		if (!InternetReadFile(hConnect,szTemp,900,&amp;dwSize))
		{
			fclose (pFile);
			cerr &lt;&lt; &quot;Error 3!&quot; &lt;&lt; endl;
			return FALSE;
		}
		if (!dwSize)
			break;
		else
		{
			fwrite(szTemp,sizeof(char),dwSize,pFile);
			size_v+=(int)dwSize;
			cout &lt;&lt; size_v/1000 &lt;&lt; &quot; kB&quot; &lt;&lt; endl &lt;&lt; flush;
		}
	}
	while (TRUE);

	fflush (pFile);
	fclose (pFile);

	return TRUE;
}

int main()
{
	char remote[500]=&quot;http://dl1.antivir-pe.de/down/windows/antivir_workstation_win7u_de_hp.exe&quot;;
	char local[500];
	HINTERNET hInternet;

	cout &lt;&lt; &quot;remote: &quot; &lt;&lt; remote &lt;&lt; endl &lt;&lt; flush;

	cout &lt;&lt; &quot;local: &quot;;
	cin &gt;&gt; local;

	hInternet=InternetOpen(NULL,INTERNET_OPEN_TYPE_PRECONFIG,NULL,0,0);
	GetFile(hInternet,remote,local);

	return 1;
}
</code></pre>
<p>warum kommt da ein fehler?<br />
klappt der code bei euch?</p>
<p>danke... Babel</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161348/laufzeitfehler-bei-code-wininet-file-aus-dem-web-saugen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 13:52:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161348.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Oct 2006 17:52:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Laufzeitfehler bei Code | WinInet | File aus dem Web saugen on Thu, 05 Oct 2006 17:52:31 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>ich versuche gerade ein programm zu schreiben welches über die WinInet-Lib<br />
eine Datei aus dem Internet herunterläd.</p>
<p>Das herunterladen kappt anscheinend auch perfekt die Datei ist lokal<br />
vollständig vorhanden!</p>
<p>aber danach kommt ein Laufzeitfehler ?!</p>
<p>hier mein code:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;iostream&gt;
#include &lt;WinINet.h&gt;

using namespace std;

#pragma comment( lib, &quot;WinINet.lib&quot; )

BOOL GetFile (HINTERNET IN hOpen,CHAR *szUrl,CHAR *szFileName)
{
	DWORD dwSize;
	CHAR szHead[] = &quot;Accept: */*\r\n\r\n&quot;;
	VOID* szTemp[25];
	HINTERNET hConnect;
	FILE* pFile;
	int size_v=0;

	if (!(hConnect=InternetOpenUrl(hOpen,szUrl,szHead,lstrlen(szHead),INTERNET_FLAG_DONT_CACHE,0)))
	{
		cerr &lt;&lt; &quot;Error 1!&quot; &lt;&lt; endl;
		return 0;
	}

	if  ( !(pFile = fopen (szFileName, &quot;wb&quot; ) ) )
	{
		cerr &lt;&lt; &quot;Error 2!&quot; &lt;&lt; endl;
		return FALSE;
	}
	do
	{
		if (!InternetReadFile(hConnect,szTemp,900,&amp;dwSize))
		{
			fclose (pFile);
			cerr &lt;&lt; &quot;Error 3!&quot; &lt;&lt; endl;
			return FALSE;
		}
		if (!dwSize)
			break;
		else
		{
			fwrite(szTemp,sizeof(char),dwSize,pFile);
			size_v+=(int)dwSize;
			cout &lt;&lt; size_v/1000 &lt;&lt; &quot; kB&quot; &lt;&lt; endl &lt;&lt; flush;
		}
	}
	while (TRUE);

	fflush (pFile);
	fclose (pFile);

	return TRUE;
}

int main()
{
	char remote[500]=&quot;http://dl1.antivir-pe.de/down/windows/antivir_workstation_win7u_de_hp.exe&quot;;
	char local[500];
	HINTERNET hInternet;

	cout &lt;&lt; &quot;remote: &quot; &lt;&lt; remote &lt;&lt; endl &lt;&lt; flush;

	cout &lt;&lt; &quot;local: &quot;;
	cin &gt;&gt; local;

	hInternet=InternetOpen(NULL,INTERNET_OPEN_TYPE_PRECONFIG,NULL,0,0);
	GetFile(hInternet,remote,local);

	return 1;
}
</code></pre>
<p>warum kommt da ein fehler?<br />
klappt der code bei euch?</p>
<p>danke... Babel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150086</guid><dc:creator><![CDATA[babelduo]]></dc:creator><pubDate>Thu, 05 Oct 2006 17:52:31 GMT</pubDate></item><item><title><![CDATA[Reply to Laufzeitfehler bei Code | WinInet | File aus dem Web saugen on Fri, 06 Oct 2006 11:54:48 GMT]]></title><description><![CDATA[<p>oder habt ihr vllt. einen anderen code der das selbe macht<br />
ohne diesen miesen fehler? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150542</guid><dc:creator><![CDATA[babelduo]]></dc:creator><pubDate>Fri, 06 Oct 2006 11:54:48 GMT</pubDate></item></channel></rss>