AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

winnet download thread

Ein Thema von drama22 · begonnen am 22. Mai 2015 · letzter Beitrag vom 23. Mai 2015
Antwort Antwort
Seite 1 von 2  1 2      
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#1

winnet download thread

  Alt 22. Mai 2015, 21:53
iam using this code to download some images from web to memory stream inside activex its freezing too much when large image size i asked on the web they told me to put this code inside a thread i fail to do it any help with it ? here is the code

Delphi-Quellcode:
procedure DownloadToStream(const Url: string; ms: TMemoryStream);
var
  hSession : HINTERNET;
  hService : HINTERNET;
  lpBuffer : array[0..1023] of Byte;
  dwBytesRead : DWORD;
  dwBytesAvail : DWORD;
  dwTimeOut : DWORD;
begin
  hSession := InternetOpen('sessionname', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  if not Assigned(hSession) then Exit;
  try
    hService := InternetOpenUrl(hSession, PChar(Url), nil, 0, 0, 0);
    if hService = nil then
      Exit;
    try
      dwTimeOut := 60000;
      InternetSetOption(hService, INTERNET_OPTION_RECEIVE_TIMEOUT, @dwTimeOut, SizeOf(dwTimeOut));
      if InternetQueryDataAvailable(hService, dwBytesAvail, 0, 0) then
      repeat
      Application.ProcessMessages;
        if not InternetReadFile(hService, @lpBuffer[0], SizeOf(lpBuffer), dwBytesRead) then
          Break;
        if dwBytesRead <> 0 then
          ms.WriteBuffer(lpBuffer[0], dwBytesRead);
      until dwBytesRead = 0;
    finally
      InternetCloseHandle(hService);
    end;
  finally
    InternetCloseHandle(hSession);
  end;
end;
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: winnet download thread

  Alt 22. Mai 2015, 22:56
Here is "I asked on the web"
http://stackoverflow.com/questions/3...-using-wininet
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#3

AW: winnet download thread

  Alt 22. Mai 2015, 23:24
yes here where i asked and i try to put the code on thread but fail any help
  Mit Zitat antworten Zitat
Medium

Registriert seit: 23. Jan 2008
3.679 Beiträge
 
Delphi 2007 Enterprise
 
#4

AW: winnet download thread

  Alt 23. Mai 2015, 00:59
Your code doesn't show any attempt to utilize a thread, and your problem description is entirely general at best. Where exactly is your problem?
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#5

AW: winnet download thread

  Alt 23. Mai 2015, 11:37
the thing is i dont know from where to start doing threading
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#6

AW: winnet download thread

  Alt 23. Mai 2015, 11:40
Easies solution: Cteate a TThread object and call your function in the execute methode.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#7

AW: winnet download thread

  Alt 23. Mai 2015, 12:01
i try to do thread like this

Delphi-Quellcode:
TDownloadThread = class(TThread)
public
  procedure Execute; override;
end;
but on thread excute what should i do
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#8

AW: winnet download thread

  Alt 23. Mai 2015, 12:22
Make your function a methode of your thread object and call that methode.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#9

AW: winnet download thread

  Alt 23. Mai 2015, 12:48
Make your function a methode of your thread object and call that methode.
dont get it how to make my procedure a method it has parmeter to be added by other string and other ms

DownloadToStream(const Url: string; ms: TMemoryStream); any code example will be more better
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#10

AW: winnet download thread

  Alt 23. Mai 2015, 12:58
Add some pubic fields to your thread object for the parameters.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:09 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz