Subir, Bajar Archivos de Texto [FTP]

Iniciado por ProcessKill, Febrero 24, 2010, 03:58:19 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Febrero 24, 2010, 03:58:19 PM Ultima modificación: Junio 03, 2013, 11:27:20 AM por Expermicid

Estas pequeñas funciones sirven  para subir y bajar archivos de texto por ftp, se usa la conexión directa y las funciones de la wininet ftpputfile y ftpgetfile para subir y bajar archivos...

para subir archivos:
Código: asm

UploadTextFile Proc Server:DWORD, User:DWORD, Pass:DWORD, LocalFileName:DWORD, RemoteFileName:DWORD
    Local hInternet:DWORD
    Local hFtp:DWORD

    invoke InternetOpen, NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0
    mov hInternet, eax

    invoke InternetConnect, hInternet, Server, 21, User, Pass,\
                         INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0


    mov hFtp, eax
    invoke FtpPutFile, hFtp, LocalFileName, RemoteFileName, FTP_TRANSFER_TYPE_ASCII, 0

    .if eax
        print "File Successfully Uploaded !", 0Dh, 0Ah
    .else
        print "Error Uploading File, Use InternetGetLastResponseInfo For More Information", 0Dh, 0Ah
    .endif

    invoke InternetCloseHandle, hInternet
    invoke InternetCloseHandle, hFtp
    xor eax, eax
    ret
UploadTextFile EndP




para bajar archivos:
Código: asm
DownloadTextFile Proc Server:DWORD, User:DWORD, Pass:DWORD, LocalFileName:DWORD, RemoteFileName:DWORD
    Local hInternet:DWORD
    Local hFtp:DWORD

    invoke InternetOpen, NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0
    mov hInternet, eax

    invoke InternetConnect, hInternet, Server, INTERNET_DEFAULT_FTP_PORT, User, Pass,\
                            INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0

    mov hFtp, eax

    invoke FtpGetFile, hFtp, RemoteFileName, LocalFileName, TRUE, FILE_ATTRIBUTE_NORMAL,\
                       FTP_TRANSFER_TYPE_ASCII, 0
    .if eax
        print "File Downloaded Successfully !", 0Dh, 0Ah
    .else
        print "Error Downloading File, Use InternetGetLastResponseInfo For More Information", 0Dh, 0Ah
    .endif

    invoke InternetCloseHandle, hInternet
    invoke InternetCloseHandle, hFtp
    xor eax, eax
    ret
DownloadTextFile EndP


En MASM hecho por pisznett


bytes ;)