Delphi-PRAXiS
Seite 2 von 3     12 3      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi .txt Datei vom Server beziehen (https://www.delphipraxis.net/114644-txt-datei-vom-server-beziehen.html)

mkinzler 28. Mai 2008 20:50

Re: .txt Datei vom Server beziehen
 
Delphi-Quellcode:
Ziel :=   'C:\index.html';

Die Muhkuh 28. Mai 2008 20:51

Re: .txt Datei vom Server beziehen
 
Du musst halt schon ein Zieldateiname angeben :zwinker:

FAlter 28. Mai 2008 20:51

Re: .txt Datei vom Server beziehen
 
Hi,

1. ist Ziel ein Dateiname und
2. hab zumindest ich keine Schreibrechte auf C:\

Mfg
FAlter

larsder4 28. Mai 2008 21:10

Re: .txt Datei vom Server beziehen
 
Es klappt immer noch nicht, irgendwas mache ich falsch.

Die Downloadzeit (falls es eine gibt) ist irsinnig schnell.

Hier ist mal der ganze Quelltext:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, XPMan, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdHTTP, UrlMon;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    XPManifest1: TXPManifest;
    StatusBar1: TStatusBar;
    Button1: TButton;
    Memo1: TMemo;
    Label2: TLabel;
    IdHTTP1: TIdHTTP;
    procedure FormCreate(Sender: TObject);
    procedure memo_nehmen(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
label2.Caption := '';
end;

procedure TForm1.memo_nehmen(Sender: TObject);
var
Quelle, Ziel: String;
begin
label2.Caption := (Sender as TButton).Caption;
Quelle := 'http://www.google.de/index.html';
Ziel :=   'C:\Dokumente und Einstellungen\Computer\Eigene Dateien\Schule\Informatik\Delphi\Hausaufgaben\index.html';
UrlDownloadToFile(nil, PChar(Quelle), PChar(Ziel), 0, nil);

end;

end.
Ich habe Administrator Rechte, dann müsste ich auch alle Schreibrechte haben.
Ich kann meinen Fehler einfach nicht finden :( :(

mkinzler 28. Mai 2008 21:13

Re: .txt Datei vom Server beziehen
 
Die Funktion funktioniert auch asynchron. Der letzte Parameter ist ein Callback. Diese wird aufgerufen, wenn sich der Status ändert. Wie ist der Returncode?

larsder4 28. Mai 2008 21:17

Re: .txt Datei vom Server beziehen
 
Gute Frage :gruebel:

Was genau ist ein Returncode?
Ich kenne diese Funktion erst seit 10 Minuten :wink:

mkinzler 28. Mai 2008 21:21

Re: .txt Datei vom Server beziehen
 
Zitat:

Zitat von OH
URLDownloadToFile Function

--------------------------------------------------------------------------------

Downloads bits from the Internet and saves them to a file.

Syntax

HRESULT URLDownloadToFile( LPUNKNOWN pCaller,
LPCTSTR szURL,
LPCTSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);
Parameters

pCaller
Pointer to the controlling IUnknown interface of the calling Microsoft ActiveX component (if the caller is an ActiveX component). If the calling application is not an ActiveX component, this value can be set to NULL. Otherwise, the caller is a Component Object Model (COM) object that is contained in another component (such as an ActiveX control within the context of an HTML page). This parameter represents the outermost IUnknown of the calling component. The function attempts the download within the context of the ActiveX client framework and allows the caller's container to receive callbacks on the progress of the download.
szURL
Pointer to a string value containing the URL to be downloaded. Cannot be set to NULL. If the URL is invalid, INET_E_DOWNLOAD_FAILURE is returned.
szFileName
Pointer to a string value containing the name of the file to create for bits that come from the download.
dwReserved
Reserved. Must be set to 0.
lpfnCB
Pointer to the caller's IBindStatusCallback interface. URLDownloadToFile calls this interface's IBindStatusCallback::OnProgress method on a connection activity, including the arrival of data. IBindStatusCallback::OnDataAvailable is never called. Implementing IBindStatusCallback::OnProgress allows a caller to implement a user interface or other progress monitoring functionality. It also allows the download operation to be canceled by returning E_ABORT from the IBindStatusCallback::OnProgress call. This can be set to NULL.
Return Value

Returns one of the following values.

S_OK The operation succeeded.
E_OUTOFMEMORY The buffer length is invalid or there was insufficient memory to complete the operation.
INET_E_DOWNLOAD_FAILURE The download of the specified resource has failed.


larsder4 28. Mai 2008 21:26

Re: .txt Datei vom Server beziehen
 
Okay, da bin ich jetzt nicht so ganz durchgestiegen :pale:

Was sollte ich denn anstelle des letzen 'nil' schreiben?

mkinzler 28. Mai 2008 21:27

Re: .txt Datei vom Server beziehen
 
Was liefert den die Funktion zurück?

larsder4 28. Mai 2008 21:31

Re: .txt Datei vom Server beziehen
 
Bei mir ja anscheinend gar nichts.

Die Funktion sollte dazu dienen, dass eine Datei aus dem Internet aufm meinen Pc geladen wird. Wird da etwas gesendet???

Sorry, aber ich bin in diesem Punkt wirklich ein ziemlicher Anfänger.


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:17 Uhr.
Seite 2 von 3     12 3      

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