<?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[datei herunter laden]]></title><description><![CDATA[<p>moien,<br />
wie kann ich eine datei herunter laden?<br />
von <a href="http://google.de/index.htm" rel="nofollow">google.de/index.htm</a> auf C:\ oder so</p>
<p>danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/153924/datei-herunter-laden</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 09:48:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/153924.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 21 Jul 2006 22:42:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to datei herunter laden on Fri, 21 Jul 2006 22:42:19 GMT]]></title><description><![CDATA[<p>moien,<br />
wie kann ich eine datei herunter laden?<br />
von <a href="http://google.de/index.htm" rel="nofollow">google.de/index.htm</a> auf C:\ oder so</p>
<p>danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1102064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102064</guid><dc:creator><![CDATA[knorke7]]></dc:creator><pubDate>Fri, 21 Jul 2006 22:42:19 GMT</pubDate></item><item><title><![CDATA[Reply to datei herunter laden on Fri, 21 Jul 2006 23:22:08 GMT]]></title><description><![CDATA[<p>Vielleicht kannst du mit folgendem Auszug aus einem Mini-Projekt von mir was anfangen:</p>
<pre><code class="language-cpp">__fastcall TDownloadThread::TDownloadThread(bool CreateSuspended,
                                            AnsiString loadFromUrl,
                                            AnsiString saveToFileName,
                                            TForm* form,
                                            HWND progressBar)
    : TThread(CreateSuspended)
{
   LoadFromURL = loadFromUrl;
   SaveToFileName = saveToFileName;
   UpdateForm = form;
   hProgressBar = progressBar;

   FreeOnTerminate = true;
}
//---------------------------------------------------------------------------

void __fastcall TDownloadThread::Execute()
{
   DownloadFile();
}
//---------------------------------------------------------------------------

void __fastcall TDownloadThread::DownloadFile()
{
    HINTERNET hInternet;
    HINTERNET hFile;
    HGLOBAL   hGlobal;
    FILE*     fFile;
    CHAR*     szBuf;
    BOOL      bGO = TRUE;
    DWORD     dwReadSize = 256;
    CHAR      lpszFileSize[15];
    INT       iStep;
    DWORD     dwDummy;
    TCHAR     szErrBuf[256];
    LPCTSTR   httpFile = LoadFromURL.c_str();
    LPCTSTR   targetFile = SaveToFileName.c_str();

    // Internet API initialisieren und Handle auf das File bekommen
    hInternet = InternetOpen(&quot;WinINet Sample Program&quot;, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
    if(!hInternet)
    {
       ShowLastErrorString();
       return;
    }
    hFile = InternetOpenUrl(hInternet, httpFile, NULL, 0, INTERNET_FLAG_RELOAD, 0);
    if(!hFile)
    {
       ShowLastErrorString();
       InternetGetLastResponseInfo(&amp;dwDummy, szErrBuf, &amp;dwReadSize);
       MessageBox(NULL, szErrBuf, &quot;Error&quot;, MB_OK | MB_ICONINFORMATION);
       InternetCloseHandle(hInternet);
       return;
    }

    // Größe des Files herausbekommen
    dwDummy = 15;
    HttpQueryInfo(hFile, HTTP_QUERY_CONTENT_LENGTH, (LPVOID)lpszFileSize, &amp;dwDummy, NULL);
    FileSize = atoi(lpszFileSize);
    if(FileSize == 0)
    {
       MessageBox(NULL, &quot;The file you want to download doesn't exist\nor has file size zero&quot;,
                  &quot;ERROR&quot;, MB_OK|MB_ICONERROR);
       InternetCloseHandle(hFile);
       InternetCloseHandle(hInternet);
       return;
    }
    iStep = (FileSize / 100 == 0) ? 1 : FileSize / 100;

    // Speicher für den Buffer allokieren
    hGlobal = GlobalAlloc(GMEM_FIXED, iStep + 1);
    szBuf = (CHAR*)GlobalLock(hGlobal);

    // Das File downloaden
    fFile = fopen(targetFile, &quot;w+b&quot;);
    while(bGO)
    {
        if(Stopped)
           break;
        bGO = InternetReadFile(hFile, szBuf, iStep, &amp;dwReadSize);
        if(bGO &amp;&amp; dwReadSize == 0)
           break;
        szBuf[dwReadSize] = '\0';
        fwrite(szBuf, 1, dwReadSize, fFile);
        DownloadedBytes += iStep;
        Synchronize(Callback);
    }
    fclose(fFile);

    // Handles schließen und aufräumen
    GlobalUnlock(hGlobal);
    GlobalFree(hGlobal);
    InternetCloseHandle(hFile);
    InternetCloseHandle(hInternet);
}
//---------------------------------------------------------------------------

void __fastcall TDownloadThread::Callback()
{
   float fFileSize = (float)FileSize;
   float fDownloadedBytes = (float)DownloadedBytes;
   int iPercent = (int)((fDownloadedBytes / fFileSize) * 100.);

   UpdateForm-&gt;Caption = (AnsiString)iPercent
                         + (AnsiString)&quot;% of &quot;
                         + SaveToFileName
                         + (AnsiString)&quot; downloaded&quot;;
   Application-&gt;Title = UpdateForm-&gt;Caption;
   SendMessage(hProgressBar, PBM_SETPOS, iPercent, 0);
}
//---------------------------------------------------------------------------

void __fastcall TDownloadThread::ShowLastErrorString()
{
    LPVOID lpMsgBuf;
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                  FORMAT_MESSAGE_FROM_SYSTEM |
                  FORMAT_MESSAGE_IGNORE_INSERTS,
                  NULL,
                  GetLastError(),
                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
                  (LPTSTR)&amp;lpMsgBuf,
                  0,
                  NULL
                 );
    MessageBox(NULL, (LPCTSTR)lpMsgBuf, &quot;Error&quot;, MB_OK | MB_ICONINFORMATION);
    LocalFree(lpMsgBuf);
}
//---------------------------------------------------------------------------

void __fastcall TDownloadThread::Stop()
{
   Stopped = true;
}
//---------------------------------------------------------------------------

void __fastcall TDownloadThread::DoTerminate()
{
   TThread::DoTerminate();

   if(DownloadedBytes &lt; FileSize)
   {
      int ans = MessageBox(UpdateForm-&gt;Handle,
                           &quot;The file has not been completely downloaded.\
                           \nDo you want it to be deleted?&quot;,
                           &quot;Information&quot;,
                           MB_YESNO|MB_ICONINFORMATION);
      if(ans == IDYES)
         DeleteFile(SaveToFileName.c_str());
   }
}
//---------------------------------------------------------------------------
</code></pre>
<p>Ach ja, du musst WinInet.lib dazulinken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1102068</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102068</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Fri, 21 Jul 2006 23:22:08 GMT</pubDate></item><item><title><![CDATA[Reply to datei herunter laden on Sat, 22 Jul 2006 03:31:34 GMT]]></title><description><![CDATA[<p>Oder mit der Indy-Komponente IdHTTP etwas kürzer:</p>
<pre><code class="language-cpp">HTTP-&gt;HandleRedirects=true; // die  IdHTTP Komponente
String Seite=HTTP-&gt;Get(&quot;http://www.xxxxxxx.de&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1102085</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102085</guid><dc:creator><![CDATA[Christian2111]]></dc:creator><pubDate>Sat, 22 Jul 2006 03:31:34 GMT</pubDate></item><item><title><![CDATA[Reply to datei herunter laden on Sat, 22 Jul 2006 08:57:21 GMT]]></title><description><![CDATA[<p>Oder so:</p>
<pre><code class="language-cpp">#include &quot;windows.h&quot;
#include &quot;urlmon.h&quot;
#pragma comment (lib, &quot;C:\urlmon.lib&quot;)
URLDownloadToFile(0, &quot;http://abc.de/ab.exe&quot;, &quot;C:\\Open.html&quot;, 0, 0);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1102125</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102125</guid><dc:creator><![CDATA[KleinHans]]></dc:creator><pubDate>Sat, 22 Jul 2006 08:57:21 GMT</pubDate></item><item><title><![CDATA[Reply to datei herunter laden on Sat, 22 Jul 2006 08:58:20 GMT]]></title><description><![CDATA[<p>wobei</p>
<pre><code class="language-cpp">#pragma comment (lib, &quot;C:\urlmon.lib&quot;)
</code></pre>
<p>nur etwas von mir ist da müsstest du gucken wo deine urlmon.lib liegt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1102126</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102126</guid><dc:creator><![CDATA[KleinHans]]></dc:creator><pubDate>Sat, 22 Jul 2006 08:58:20 GMT</pubDate></item><item><title><![CDATA[Reply to datei herunter laden on Sat, 22 Jul 2006 09:31:33 GMT]]></title><description><![CDATA[<p>hmm...<br />
wenn ich das mit der urlmon.lib nehme, und die urlmon.lib wie bei dir auf laufwerk C:/ liegt, muss dann bei jedem, den man das programm gibt nicht auch die urlmon.lib auf C:/ rumgammeln, damit es funzt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1102136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102136</guid><dc:creator><![CDATA[vale]]></dc:creator><pubDate>Sat, 22 Jul 2006 09:31:33 GMT</pubDate></item><item><title><![CDATA[Reply to datei herunter laden on Sat, 22 Jul 2006 10:19:48 GMT]]></title><description><![CDATA[<p>Du kannst ja die lib mit dem Programm weitergeben und in dem selbem Ordner speichern. Danach kannst Du sie ja mit Application-&gt;ExeName... einbinden.</p>
<p>Die Variante von Christian211(1) ist aber meines Erachtens nach die beste und unkomplizierteste.</p>
<p>Gruss</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1102153</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102153</guid><dc:creator><![CDATA[Rostfrei**]]></dc:creator><pubDate>Sat, 22 Jul 2006 10:19:48 GMT</pubDate></item><item><title><![CDATA[Reply to datei herunter laden on Sat, 22 Jul 2006 19:54:08 GMT]]></title><description><![CDATA[<p>nein die urlmon.lib muss nicht mitgegeben werden die wird so mit eincompiliert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1102363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102363</guid><dc:creator><![CDATA[KleinHans]]></dc:creator><pubDate>Sat, 22 Jul 2006 19:54:08 GMT</pubDate></item></channel></rss>