AGB  ·  Datenschutz  ·  Impressum  







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

FTP status anzeige

Ein Thema von 1234588 · begonnen am 17. Mai 2007 · letzter Beitrag vom 25. Mai 2007
Antwort Antwort
Seite 2 von 2     12   
1234588

Registriert seit: 14. Jan 2007
Ort: Stuttgart
164 Beiträge
 
#11

Re: FTP status anzeige

  Alt 18. Mai 2007, 00:53
schande ueber mich..

vielen dank =D
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

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

Re: FTP status anzeige

  Alt 18. Mai 2007, 01:08
Delphi-Quellcode:
uses
  Windows,
  WinInet,
  WinSock,
  SysUtils;

procedure StatusCallback(hInet: HINTERNET; Context, Status: DWORD; pInformation: Pointer; InfoLength: DWORD); stdcall;
var
  s : string;
begin
  case Status of
    INTERNET_STATUS_CLOSING_CONNECTION: s := 'Closing the connection to the server';
    INTERNET_STATUS_CONNECTED_TO_SERVER: s := 'Successfully connected to the socket address: ' + IntToStr((sockaddr_in(pInformation).sin_port));
    INTERNET_STATUS_CONNECTING_TO_SERVER: s := 'Connecting to the socket address';
    INTERNET_STATUS_CONNECTION_CLOSED: s := 'Successfully closed the connection to the server';
// INTERNET_STATUS_COOKIE_HISTORY: s := 'Retrieving content from the cache.';
// INTERNET_STATUS_COOKIE_RECEIVED: s := 'Indicates the number of cookies';
// INTERNET_STATUS_COOKIE_SENT: s := 'number of cookies that were either sent or suppressed';
    INTERNET_STATUS_CTL_RESPONSE_RECEIVED: s := 'Not implemented';
// INTERNET_STATUS_DETECTING_PROXY: s := 'Notifies the client application that a proxy has been detected.';
    INTERNET_STATUS_HANDLE_CLOSING: s := 'This handle value has been terminated';
    INTERNET_STATUS_HANDLE_CREATED: s := 'InternetConnect has created the new handle';
    INTERNET_STATUS_INTERMEDIATE_RESPONSE: s :=
      'Received an intermediate (100 level) status code message from the server';
    INTERNET_STATUS_NAME_RESOLVED: s := 'Successfully found the IP address: ' + PChar(pInformation);
// INTERNET_STATUS_P3P_HEADER: s := 'The response has a P3P header in it.';
// INTERNET_STATUS_P3P_POLICYREF: s := 'Not implemented.';
    INTERNET_STATUS_PREFETCH: s := 'Not implemented';
// INTERNET_STATUS_PRIVACY_IMPACTED: s := 'Not implemented.';
    INTERNET_STATUS_RECEIVING_RESPONSE: s := 'Waiting for the server to respond to a request ';
    INTERNET_STATUS_REDIRECT: s := 'HTTP request is about to automatically redirect the request ' +
      PChar(pInformation);
    INTERNET_STATUS_REQUEST_COMPLETE: s := 'An asynchronous operation has been completed';
    INTERNET_STATUS_REQUEST_SENT: s := 'Successfully sent the information request to the server: ' +
      IntToStr(Integer(pInformation)) + ' Byte';
    INTERNET_STATUS_RESOLVING_NAME: s := 'Looking up the IP address: ' + PChar(pInformation);
    INTERNET_STATUS_RESPONSE_RECEIVED: s := 'Successfully received a response from the server: ' +
      IntToStr(Integer(pInformation)) + ' Byte';
    INTERNET_STATUS_SENDING_REQUEST: s := 'Sending the information request to the server.';
    INTERNET_STATUS_STATE_CHANGE:
      begin
        s := 'Moved between a secure (HTTPS) and a nonsecure (HTTP) site.';
        case DWORD(pInformation) of
          INTERNET_STATE_CONNECTED: s := s + #13#10 + 'Connected state. Mutually exclusive with disconnected state.';
          INTERNET_STATE_DISCONNECTED: s := s + #13#10 +
            'Disconnected state. No network connection could be established.';
          INTERNET_STATE_DISCONNECTED_BY_USER: s := s + #13#10 + 'Disconnected by user request.';
          INTERNET_STATE_IDLE: s := s + #13#10 + 'No network requests are being made by Windows Internet.';
          INTERNET_STATE_BUSY: s := s + #13#10 + 'Network requests are being made by Windows Internet.';
// INTERNET_STATUS_USER_INPUT_REQUIRED: s := s + #13#10 + 'he request requires user input to be completed.';
        end;
      end;
  end;
  Writeln(s);
end;

function PutFile(server, username, password, localfile, remotefile: string; port: word = 21): boolean;
var
  hopen, hconnect : HINTERNET;
begin
  hopen := InternetOpen('test', INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);
  if Assigned(hopen) then
  begin
    InternetSetStatusCallback(hopen, @StatusCallback);
    hconnect := InternetConnect(hopen, pchar(server), port, pchar(username), pchar(password), INTERNET_SERVICE_FTP,
      INTERNET_FLAG_PASSIVE, 1);
    if Assigned(hconnect) then
    begin
      Result := FtpPutFile(hconnect, pchar(localfile), pchar(remotefile), FTP_TRANSFER_TYPE_UNKNOWN, 1);
      InternetCloseHandle(hconnect);
    end
    else
      Result := False;
  end
  else
    Result := False;
end;

begin
  if not PutFile('michael-puff.de', 'l3s11195', 'wd8y7rcv', 'd:\CU_A1804.SAV', 'html/CU_A1804.SAV') then
    Writeln(SysErrorMessage(GetLastError));
  Writeln('Done');
  Readln;
end.
So geht es bis auf Zeile 13, da meint er ungültiger Typecast. Wenn sich das hjmand noch mal angucken könnte? Da müsste in pInformation ein Zeiger auf eine sockaddr_in Struktur stehen mit der man Adresse und Port bestimmen kann. Das hab eich aber leider nicht hinbekommen.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
CCRDude
(Gast)

n/a Beiträge
 
#13

Re: FTP status anzeige

  Alt 18. Mai 2007, 08:36
sockaddr_in ist doch auch ein Record und kein Zeiger auf jenes? Da solltest Du wahrscheinlich eher ein PSockAddrIn verwenden...
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

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

Re: FTP status anzeige

  Alt 18. Mai 2007, 11:46
Ah, ja. Dann geht es, aber meine Demo zeigt mir als Port 13358 an, ein Portmonitor aber 1089 bzw 1092. Und wie kommt man über diese Information an die IP-Adresse dran?
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
Benutzerbild von Sunlight7
Sunlight7

Registriert seit: 17. Sep 2006
Ort: Sonnensystem, Zentral
1.522 Beiträge
 
Delphi 5 Standard
 
#15

Re: FTP status anzeige

  Alt 25. Mai 2007, 04:46
Moin!

Da ich grad den Code von jemanden überarbeite, der diese Callback eingebaut hat.
Der Typecast ist falsch:

IntToStr(Integer(pInformation)) + ' Byte'; Das macht einen Integer aus der Pointeradresse

IntToStr(Integer(pInformation^)) + ' Byte'; So klappts dann auch mit dem Nachbarn.
Windows: Ja - Microsoft: Nein -> www.ReactOS.org
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 2     12   


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 15: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