Login
Buscar
Quem está conectado
Há 5 usuários online :: Nenhum usuário registrado, Nenhum Invisível e 5 Visitantes :: 2 Motores de buscaNenhum
[ Ver toda a lista ]
O recorde de usuários online foi de 71 em 19/7/2010, 11:47
Brasília
| |
Estamos no Twitter

Nossa Comunidade

Nosso Grupo

Últimos assuntos
Top dos mais postadores
| Marcos Guedes | ||||
| hugo | ||||
| alceu11 | ||||
| Julio | ||||
| marcelofazan | ||||
| mfelis | ||||
| cabeludo | ||||
| Tales Ruan | ||||
| Nelson Arcas | ||||
| marcio |
Contagem Regressiva em tela de login
16/7/2010, 11:10 por Linghston
Ola amigos, esta é minha primeira participação neste forum e espero poder encontar aqui ajuda para ...
Comentários: 15
Estatísticas
Temos 926 usuários registradosO último usuário registrado atende pelo nome de Maria Tognetti
Os nossos membros postaram um total de 8596 mensagens em 1239 assuntos
Saber Total de KB já Baixados pelo FTP
Página 1 de 2 • Compartilhe •
Página 1 de 2 • 1, 2 
Saber Total de KB já Baixados pelo FTP
Olá.Pessoal.
Crie um DLL chamada FTPNET.ele tem a função de como o nome diz conectar e fazer transferença de arquivos [Você precisa estar registrado e conectado para ver este link.] gostaria de colocar uma Função que me Indique o Tamanho Total do Arquivo em KB, e quanto já baixou em KB tambem.
Alguém AJuda.Obrigado!!
Crie um DLL chamada FTPNET.ele tem a função de como o nome diz conectar e fazer transferença de arquivos [Você precisa estar registrado e conectado para ver este link.] gostaria de colocar uma Função que me Indique o Tamanho Total do Arquivo em KB, e quanto já baixou em KB tambem.
Alguém AJuda.Obrigado!!

mfelis- Participa Bastante

Re: Saber Total de KB já Baixados pelo FTP
qual código que estais utilizando?
caso seja um que indiquei, já vem contido num cursor o tamanho do arquivo.
caso seja um que indiquei, já vem contido num cursor o tamanho do arquivo.
_________________
Marcos Guedes - Programador e desenvolvedor Web.
Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

Marcos Guedes- Webmaster

Re: Saber Total de KB já Baixados pelo FTP
Uso Funções do Wininet.
- Código:
* Internet API Returns
**********************
#Define ERROR_SUCCESS 0
#Define ERROR_FILE_NOT_FOUND 2
#Define ERROR_PATH_NOT_FOUND 3
#Define ERROR_ACCESS_DENIED 5
#Define ERROR_INVALID_HANDLE 6
#Define ERROR_NO_MORE_FILES 18
#Define ERROR_FILE_EXISTS 80
#Define ERROR_INVALID_PARAMETER 87
#Define ERROR_INTERNET_BASE 12000
#Define ERROR_INTERNET_OUT_OF_HANDLES (ERROR_INTERNET_BASE + 1)
#Define ERROR_INTERNET_TIMEOUT (ERROR_INTERNET_BASE + 2)
#Define ERROR_INTERNET_EXTENDED_ERROR (ERROR_INTERNET_BASE + 3)
#Define ERROR_INTERNET_INTERNAL_ERROR (ERROR_INTERNET_BASE + 4)
#Define ERROR_INTERNET_INVALID_URL (ERROR_INTERNET_BASE + 5)
#Define ERROR_INTERNET_UNRECOGNIZED_SCHEME (ERROR_INTERNET_BASE + 6)
#Define ERROR_INTERNET_NAME_NOT_RESOLVED (ERROR_INTERNET_BASE + 7)
#Define ERROR_INTERNET_PROTOCOL_NOT_FOUND (ERROR_INTERNET_BASE + 8)
#Define ERROR_INTERNET_INVALID_OPTION (ERROR_INTERNET_BASE + 9)
#Define ERROR_INTERNET_BAD_OPTION_LENGTH (ERROR_INTERNET_BASE + 10)
#Define ERROR_INTERNET_OPTION_NOT_SETTABLE (ERROR_INTERNET_BASE + 11)
#Define ERROR_INTERNET_SHUTDOWN (ERROR_INTERNET_BASE + 12)
#Define ERROR_INTERNET_INCORRECT_USER_NAME (ERROR_INTERNET_BASE + 13)
#Define ERROR_INTERNET_INCORRECT_PASSWORD (ERROR_INTERNET_BASE + 14)
#Define ERROR_INTERNET_LOGIN_FAILURE (ERROR_INTERNET_BASE + 15)
#Define ERROR_INTERNET_INVALID_OPERATION (ERROR_INTERNET_BASE + 16)
#Define ERROR_INTERNET_OPERATION_CANCELLED (ERROR_INTERNET_BASE + 17)
#Define ERROR_INTERNET_INCORRECT_HANDLE_TYPE (ERROR_INTERNET_BASE + 18)
#Define ERROR_INTERNET_INCORRECT_HANDLE_STATE (ERROR_INTERNET_BASE + 19)
#Define ERROR_INTERNET_NOT_PROXY_REQUEST (ERROR_INTERNET_BASE + 20)
#Define ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND (ERROR_INTERNET_BASE + 21)
#Define ERROR_INTERNET_BAD_REGISTRY_PARAMETER (ERROR_INTERNET_BASE + 22)
#Define ERROR_INTERNET_NO_DIRECT_ACCESS (ERROR_INTERNET_BASE + 23)
#Define ERROR_INTERNET_NO_CONTEXT (ERROR_INTERNET_BASE + 24)
#Define ERROR_INTERNET_NO_CALLBACK (ERROR_INTERNET_BASE + 25)
#Define ERROR_INTERNET_REQUEST_PENDING (ERROR_INTERNET_BASE + 26)
#Define ERROR_INTERNET_INCORRECT_FORMAT (ERROR_INTERNET_BASE + 27)
#Define ERROR_INTERNET_ITEM_NOT_FOUND (ERROR_INTERNET_BASE + 28)
#Define ERROR_INTERNET_CANNOT_CONNECT (ERROR_INTERNET_BASE + 29)
#Define ERROR_INTERNET_CONNECTION_ABORTED (ERROR_INTERNET_BASE + 30)
#Define ERROR_INTERNET_CONNECTION_RESET (ERROR_INTERNET_BASE + 31)
#Define ERROR_INTERNET_FORCE_RETRY (ERROR_INTERNET_BASE + 32)
#Define ERROR_INTERNET_INVALID_PROXY_REQUEST (ERROR_INTERNET_BASE + 33)
#Define ERROR_INTERNET_NEED_UI (ERROR_INTERNET_BASE + 34)
#Define ERROR_INTERNET_HANDLE_EXISTS (ERROR_INTERNET_BASE + 36)
#Define ERROR_INTERNET_SEC_CERT_DATE_INVALID (ERROR_INTERNET_BASE + 37)
#Define ERROR_INTERNET_SEC_CERT_CN_INVALID (ERROR_INTERNET_BASE + 38)
#Define ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR (ERROR_INTERNET_BASE + 39)
#Define ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR (ERROR_INTERNET_BASE + 40)
#Define ERROR_INTERNET_MIXED_SECURITY (ERROR_INTERNET_BASE + 41)
#Define ERROR_INTERNET_CHG_POST_IS_NON_SECURE (ERROR_INTERNET_BASE + 42)
#Define ERROR_INTERNET_POST_IS_NON_SECURE (ERROR_INTERNET_BASE + 43)
#Define ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED (ERROR_INTERNET_BASE + 44)
#Define ERROR_INTERNET_INVALID_CA (ERROR_INTERNET_BASE + 45)
#Define ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP (ERROR_INTERNET_BASE + 46)
#Define ERROR_INTERNET_ASYNC_THREAD_FAILED (ERROR_INTERNET_BASE + 47)
#Define ERROR_INTERNET_REDIRECT_SCHEME_CHANGE (ERROR_INTERNET_BASE + 48)
#Define ERROR_INTERNET_DIALOG_PENDING (ERROR_INTERNET_BASE + 49)
#Define ERROR_INTERNET_RETRY_DIALOG (ERROR_INTERNET_BASE + 50)
#Define ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR (ERROR_INTERNET_BASE + 52)
#Define ERROR_INTERNET_INSERT_CDROM (ERROR_INTERNET_BASE + 53)
*
* FTP API errors
*
#Define FTP_TRANSFER_IN_PROGRESS (ERROR_INTERNET_BASE + 110)
#Define FTP_DROPPED (ERROR_INTERNET_BASE + 111)
#Define FTP_NO_PASSIVE_MODE (ERROR_INTERNET_BASE + 112)
*
* additional Internet API error codes
*
#Define ERROR_INTERNET_SECURITY_CHANNEL_ERROR (ERROR_INTERNET_BASE + 157)
#Define ERROR_INTERNET_UNABLE_TO_CACHE_FILE (ERROR_INTERNET_BASE + 158)
#Define ERROR_INTERNET_TCPIP_NOT_INSTALLED (ERROR_INTERNET_BASE + 159)
#Define ERROR_INTERNET_DISCONNECTED (ERROR_INTERNET_BASE + 163)
#Define ERROR_INTERNET_SERVER_UNREACHABLE (ERROR_INTERNET_BASE + 164)
#Define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (ERROR_INTERNET_BASE + 165)
#Define ERROR_INTERNET_BAD_AUTO_PROXY_script (ERROR_INTERNET_BASE + 166)
#Define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_script (ERROR_INTERNET_BASE + 167)
#Define ERROR_INTERNET_SEC_INVALID_CERT (ERROR_INTERNET_BASE + 169)
#Define ERROR_INTERNET_SEC_CERT_REVOKED (ERROR_INTERNET_BASE + 170)
*
* handle types
*
#Define ERROR_INTERNET_HANDLE_TYPE_INTERNET 1
#Define ERROR_INTERNET_HANDLE_TYPE_CONNECT_FTP 2
#Define ERROR_INTERNET_HANDLE_TYPE_CONNECT_GOPHER 3
#Define ERROR_INTERNET_HANDLE_TYPE_CONNECT_HTTP 4
#Define ERROR_INTERNET_HANDLE_TYPE_FTP_FIND 5
#Define ERROR_INTERNET_HANDLE_TYPE_FTP_FIND_HTML 6
#Define ERROR_INTERNET_HANDLE_TYPE_FTP_FILE 7
#Define ERROR_INTERNET_HANDLE_TYPE_FTP_FILE_HTML 8
#Define ERROR_INTERNET_HANDLE_TYPE_GOPHER_FIND 9
#Define ERROR_INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML 10
#Define ERROR_INTERNET_HANDLE_TYPE_GOPHER_FILE 11
#Define ERROR_INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML 12
#Define ERROR_INTERNET_HANDLE_TYPE_HTTP_REQUEST 13
#Define BYTE_1 1
#Define BYTE_2 256
#Define BYTE_3 65536
#Define BYTE_4 16777216
#Define MAXDWORD 4294967295
*
* File Caching Flags
*
#Define INTERNET_FLAG_DONT_CACHE 67108864
#Define INTERNET_FLAG_HYPERLINK 1024
#Define INTERNET_FLAG_MAKE_PERSISTENT 33554432
#Define INTERNET_FLAG_MUST_CACHE_REQUEST 16
#Define INTERNET_FLAG_RELOAD 2147483648
#Define INTERNET_FLAG_NO_CACHE_WRITE 67108864
#Define INTERNET_FLAG_RESYNCHRONIZE 2048
*
* File Attributes
*
#Define FILE_ATTRIBUTE_READONLY 1
#Define FILE_ATTRIBUTE_HIDDEN 2
#Define FILE_ATTRIBUTE_SYSTEM 4
#Define FILE_ATTRIBUTE_DIRECTORY 16
#Define FILE_ATTRIBUTE_ARCHIVE 32
#Define FILE_ATTRIBUTE_ENCRYPTED 64
#Define FILE_ATTRIBUTE_NORMAL 128
#Define FILE_ATTRIBUTE_TEMPORARY 256
#Define FILE_ATTRIBUTE_SPARSE_FILE 512
#Define FILE_ATTRIBUTE_REPARSE_POINT 1024
#Define FILE_ATTRIBUTE_COMPRESSED 2048
#Define FILE_ATTRIBUTE_OFFLINE 4096
#Define BIT_ATTRIBUTE_READONLY 0
#Define BIT_ATTRIBUTE_HIDDEN 1
#Define BIT_ATTRIBUTE_SYSTEM 2
#Define BIT_ATTRIBUTE_DIRECTORY 4
#Define BIT_ATTRIBUTE_ARCHIVE 5
#Define BIT_ATTRIBUTE_ENCRYPTED 6
#Define BIT_ATTRIBUTE_NORMAL 7
#Define BIT_ATTRIBUTE_TEMPORARY 8
#Define BIT_ATTRIBUTE_SPARSE_FILE 9
#Define BIT_ATTRIBUTE_REPARSE_POINT 10
#Define BIT_ATTRIBUTE_COMPRESSED 11
#Define BIT_ATTRIBUTE_OFFLINE 12
* Flags for InternetAutodial
#Define INTERNET_AUTODIAL_FORCE_ONLINE 1
#Define INTERNET_AUTODIAL_FORCE_UNATTENDED 2
#Define INTERNET_AUTODIAL_FAILIFSECURITYCHECK 4
*
* FTP
*TYPE
#Define FTP_TRANSFER_TYPE_UNKNOWN 0
#Define FTP_TRANSFER_TYPE_ASCII 1
#Define FTP_TRANSFER_TYPE_BINARY 2
* Flags for InternetGetConnectedState
#Define INTERNET_CONNECTION_MODEM 1
#Define INTERNET_CONNECTION_LAN 2
#Define INTERNET_CONNECTION_PROXY 4
#Define INTERNET_CONNECTION_MODEM_BUSY 8
#Define FTP_TRANSFER_TYPE_MASK 3 && (FTP_TRANSFER_TYPE_ASCII | FTP_TRANSFER_TYPE_BINARY)
*
* Internet Variables
#Define INTERNET_DEFAULT FTP_PORT 21
#Define INTERNET_SERVICE_FTP 1
#Define INTERNET_OPEN_TYPE_DIRECT 1
#Define INTERNET_CONNECT_FLAG_PASSIVE
#Define cNULL Chr(0)
#Define MAX_PATH 260
****************************************************
* Class Ftp_Service *
****************************************************
Define Class ftp_Service As Custom OlePublic
cIPAddress = ""
cUserName = ""
cPassword = ""
cPort = "21" && Default FTP PORT
nInet_Handle = 0
nConnect_Handle = 0
lDLL_Loaded = .F.
nResult_Code = 0
nExtended_Result = 0
cExtended_Message = ""
cCurrentDir = ""
nCachingType = INTERNET_FLAG_DONT_CACHE
cAgent = "Visual FoxPro" + cNULL
****************************************************
Procedure Init
This.LoadApiFuncs()
If _Dos Or _Unix Or _Mac
Return .F.
Endif
Endproc
****************************************************
Procedure LoadApiFuncs
* Variables need for defines
Local lpcAgent, nAccessType, lpcProxyName, lpcProxyBypass, nFlags
Local nInet_Handle, nConnect_Handle, lpcServer, nPort, lpcUserName
Local lpcPassword, nService, nContext, nMax_Path
Local lpcDirectory, lpcFileName, lpcSearchStr, lpcWIN32_FIND_DATA
Local lpcRemoteFile, lpcNewFile, nFailIfExists, nAttributes
Local nError, lpcBuffer, nHandle, lpcDialUp
* Check to see if We have already declared functions and loaded the DLL
If This.lDLL_Loaded
Return ERROR_SUCCESS
Endif
* Declare a Kernel32 Functions
Declare Integer GetLastError In Kernel32
Declare Integer FileTimeToSystemTime In Kernel32 ;
STRING @lpcBuffer, String @lpcBuffer
* Declare DLL functions used by Program
Declare Integer InternetAutodial In WinInet ;
INTEGER nAccessType, Integer nHandle
Declare Integer InternetAutodialHangup In WinInet ;
INTEGER nFlags
Declare Integer InternetDial In WinInet ;
INTEGER nHandle, String @lpcDialUp, Integer nAccessType, Integer @nConnect_Handle, ;
INTEGER nFlags
Declare Integer InternetHangUp In WinInet ;
INTEGER nConnect_Handle, Integer nFlags
Declare Integer InternetGetConnectedState In WinInet ;
INTEGER @nContext, Integer nFlags
Declare Integer InternetGoOnline In WinInet ;
STRING @lpcURL, Integer nHandle, Integer nFlags
Declare Integer InternetOpen In WinInet ;
STRING @lpcAgent, Integer nAccessType, String @lpcProxyName, ;
STRING @lpcProxyBypass, Integer nFlags
Declare Integer InternetConnect In WinInet ;
INTEGER nInet_Handle, String @lpcServer, Short nPort, String @lpcUserName, ;
STRING @lpcPassword, Integer nService, Integer nFlags, Integer nContext
Declare Integer InternetCloseHandle In WinInet ;
INTEGER nConnect_Handle
* FTP Functions
Declare Integer FtpCreateDirectory In WinInet ;
INTEGER nConnect_Handle, String @lpcDirectory
Declare Integer FtpDeleteFile In WinInet ;
INTEGER nConnect_Handle, String @lpcFileName
Declare Integer FtpFindFirstFile In WinInet ;
INTEGER nConnect_Handle, String @lpcSearchStr, String @lpcWIN32_FIND_DATA, ;
INTEGER nFlags, Integer nContext
Declare Integer InternetFindNextFile In WinInet ;
INTEGER nConnect_Handle, String @lpcWIN32_FIND_DATA
Declare Integer FtpGetCurrentDirectory In WinInet ;
INTEGER nConnect_Handle, String @lpcDirectory, Integer @nMax_Path
Declare Integer FtpGetFile In WinInet ;
INTEGER nConnect_Handle, String @lpcRemoteFile, String @lpcNewFile, ;
INTEGER nFailIfExists, Integer nAttributes, Integer nFlags, ;
INTEGER nContext
Declare Integer FtpOpenFile In WinInet ;
INTEGER nConnect_Handle, String @lpcRemoteFile, Integer nAccessType, ;
INTEGER nFlags, Integer nContext
Declare Integer FtpPutFile In WinInet ;
INTEGER nConnect_Handle, String @lpcNewFile, String @lpcRemoteFile, ;
INTEGER nFlags, Integer nContext
Declare Integer FtpRemoveDirectory In WinInet ;
INTEGER nConnect_Handle, String @lpcDirectory
Declare Integer FtpRenameFile In WinInet ;
INTEGER nConnect_Handle, String @lpcRemoteFile, String @lpcNewFile
Declare Integer FtpSetCurrentDirectory In WinInet ;
INTEGER nConnect_Handle, String @lpcDirectory
Declare Integer InternetGetLastResponseInfo In WinInet ;
INTEGER @nError, String @lpcBuffer, Integer @nMax_Path
This.lDLL_Loaded = .T.
Return ERROR_SUCCESS
Endproc
****************************************************
Procedure AutoDialInternet
Lparameters lnType
Local lnHWNDHandle, fResult
If This.LoadApiFuncs() != ERROR_SUCCESS
Return .F.
Endif
If Type(lnType) != "N"
Return .F.
Endif
lnHWNDHandle = 0
fResult = InternetAutodial(lnType, lnHWNDHandle)
This.GetExtendedError()
If fResult = 0
Return .F.
Endif
Return .T.
Endproc
****************************************************
Procedure AutoDialHangUp
Local fResult
If This.LoadApiFuncs() != ERROR_SUCCESS
Return .F.
Endif
fResult = InternetAutodialHangup(0)
This.GetExtendedError()
If fResult = 0
Return .F.
Endif
Return .T.
Endproc
****************************************************
Procedure DialInternet
Lparameters lcDialUpName, lnFlag
Local fResult, lnConnectionID, lnHWNDHandle
If This.LoadApiFuncs() != ERROR_SUCCESS
Return -1
Endif
lnConnectionID = 0
lnHWNDHandle = 0
If Type("lcDialUpName") != "C" Or ;
TYPE("lnFlag") != "N"
Return -1
Endif
If Len(Alltrim(lcDialUpName)) = 0
Return -1
Endif
lcDialUpName = lcDialUpName + cNULL
fResult = InternetDial(lnHWNDHandle, @lcDialUpName, lnFlag, @lnConnectionID, 0)
This.GetExtendedError()
Return lnConnectionID
Endproc
****************************************************
Procedure DialHangUp
Lparameters lnConnectionID
Local fResult
If This.LoadApiFuncs() != ERROR_SUCCESS
Return -1
Endif
If Type("lnConnectionID") != "N"
Return .F.
Endif
fResult = InternetHangUp(@lnConnectionID, 0)
This.GetExtendedError()
If fResult = 0
Return .F.
Else
Return .T.
Endif
Endproc
****************************************************
Procedure GetConnectedState
Local fResult, lnConnectionState
If This.LoadApiFuncs() != ERROR_SUCCESS
Return -1
Endif
lnConnectionState = 0
fResult = InternetGetConnectedState(@lnConnectionState, 0)
This.GetExtendedError()
If fResult = 0
Return -1
Endif
Return lnConnectionState
Endproc
****************************************************
Procedure GoOnline
Lparameters lcURL
Local lnHWNDHandle, fResult
If This.LoadApiFuncs() != ERROR_SUCCESS
Return -1
Endif
If Type("lcURL") != "C"
Return .F.
Endif
lcURL = lcURL + cNULL
lnHWNDHandle = 0
fResult = InternetGoOnline(@lcURL, lnHWNDHandle, 0)
This.GetExtendedError()
If fResult = 0
Return .F.
Else
Return .T.
Endif
Endproc
****************************************************
Procedure OpenInternet
Lparameters lcUserName, lcPassword, lcIPAddress, lcPort
Local lnPCount, fResult, lcTempDir, lnConnectHandle
* Check Passed Parameters
lnPCount = Parameters()
If lnPCount <> 4
nResult_Code = ERROR_INTERNET_BAD_OPTION_LENGTH
Return .F.
Endif
* Make sure parameters are of the correct type
If (Type("lcUserName") != "C") Or ;
(Type("lcPassword") != "C") Or ;
(Type("lcIPAddress") != "C") Or ;
(Type("lcPort") != "C")
nResult_Code = ERROR_INVALID_PARAMETER
Return .F.
Endif
* Check Parameter Values
If Empty(lcUserName) Or Empty(lcPassword) Or Empty(lcIPAddress)
nResult_Code = ERROR_INTERNET_BAD_OPTION_LENGTH
Return .F.
Endif
If This.LoadApiFuncs() != ERROR_SUCCESS
Return .F.
Endif
* Open Handle to Internet
* Set Parameters
This.cUserName = lcUserName + cNULL && Store FTP Connection information
This.cPassword = lcPassword + cNULL
This.cIPAddress = lcIPAddress + cNULL
This.cPort = lcPort
This.nInet_Handle = InternetOpen((This.cAgent), INTERNET_OPEN_TYPE_DIRECT, cNULL, cNULL, 0)
This.GetExtendedError()
* Unable to Get a Connection into the Internet
If This.nInet_Handle = 0
This.CloseFtp()
Return .F.
Endif
* This Opens the FTP site and Gets the Current Directory. The handle to the FTP site is opened
* and closed for each call to any function.
* Open FTP Site
lnConnect_Handle = InternetConnect(This.nInet_Handle, (This.cIPAddress), Val(lcPort), ;
(This.cUserName), (This.cPassword), INTERNET_SERVICE_FTP, 0, 0)
This.GetExtendedError()
If lnConnect_Handle != 0
lcTempDir = Space(MAX_PATH)
fResult = FtpGetCurrentDirectory(lnConnect_Handle, @lcTempDir, MAX_PATH)
This.GetExtendedError()
If fResult != 0
This.cCurrentDir = lcTempDir
InternetCloseHandle(lnConnect_Handle)
Else
Return .F.
Endif
Else
Return .F.
Endif
Return .T.
Endproc
****************************************************
Procedure OpenFtpConnection
Local nHandle, lnConnect_Handle, lcCurrentDir
* Open FTP Site
lnConnect_Handle = InternetConnect(This.nInet_Handle, (This.cIPAddress), Val(This.cPort), ;
(This.cUserName), (This.cPassword), INTERNET_SERVICE_FTP, 0, 0)
This.GetExtendedError()
lcCurrentDir = This.cCurrentDir
If lnConnect_Handle != 0
fResult = FtpSetCurrentDirectory(lnConnect_Handle, @lcCurrentDir)
If fResult = 1
This.nConnect_Handle = lnConnect_Handle
Return .T.
Else
This.GetExtendedError() && Only Get extended Error information when there is an error
Return .F.
Endif
Else
Return .F.
Endif
Endproc
****************************************************
Procedure CloseFtpConnection
If This.nConnect_Handle != 0
InternetCloseHandle(This.nConnect_Handle)
Endif
This.nConnect_Handle = 0
Return
Endproc
****************************************************
Procedure CloseInternet
* Handles have a Hierarchy. Closing the Top Handle will close all child handles also.
If This.nInet_Handle != 0
InternetCloseHandle(This.nInet_Handle)
This.nInet_Handle = 0
Endif
Endproc
****************************************************
Procedure SetCachingMethod
Lparameters nCacheType
Local fResult
fResult = .F.
* only change caching type if we have a valid new cache type
Do Case
Case nCacheType = INTERNET_FLAG_DONT_CACHE
This.nCachingType = INTERNET_FLAG_DONT_CACHE
fResult = .T.
Case nCacheType = INTERNET_FLAG_HYPERLINK
This.nCachingType = INTERNET_FLAG_HYPERLINK
fResult = .T.
Case nCacheType = INTERNET_FLAG_MAKE_PERSISTENT
This.nCachingType = INTERNET_FLAG_MAKE_PERSISTENT
fResult = .T.
Case nCacheType = INTERNET_FLAG_MUST_CACHE_REQUEST
This.nCachingType = INTERNET_FLAG_MUST_CACHE_REQUEST
fResult = .T.
Case nCacheType = INTERNET_FLAG_RELOAD
This.nCachingType = INTERNET_FLAG_RELOAD
fResult = .T.
Case nCacheType = INTERNET_FLAG_NO_CACHE_WRITE
This.nCachingType = INTERNET_FLAG_NO_CACHE_WRITE
fResult = .T.
Case nCacheType = INTERNET_FLAG_RESYNCHRONIZE
This.nCachingType = INTERNET_FLAG_RESYNCHRONIZE
fResult = .T.
Endcase
Return fResult
Endproc
****************************************************
Procedure GetCachingMethod
Return This.nCachingType
Endproc
****************************************************
Procedure GetFtpFile
Lparameters lcRemoteFile, lcNewFile, llFailIfExists
Local fResult, lnFail
If This.OpenFtpConnection() && Open an FTP Handle
If llFailIfExists
lnFail = 1
Else
lnFail = 0
Endif
lcNewFile = lcNewFile + cNULL
lcRemoteFile = lcRemoteFile + cNULL
fResult = FtpGetFile(This.nConnect_Handle, @lcRemoteFile, @lcNewFile, lnFail, ;
FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY + This.nCachingType, 0)
This.GetExtendedError()
This.CloseFtpConnection() && Close FTP Handle
If fResult = 1
Return .T.
Else
Return .F.
Endif
Endif
Endproc
Procedure PutFtpFile(lcRemoteFile, lclocalFile)
*#*********************************************
Local fResult
If This.OpenFtpConnection() && Open an FTP Handle
lcRemoteFile = lcRemoteFile + cNULL
lclocalFile = lclocalFile + cNULL
fResult = FtpPutFile(This.nConnect_Handle, @lclocalFile, @lcRemoteFile, FTP_TRANSFER_TYPE_BINARY, 0)
This.GetExtendedError()
This.CloseFtpConnection()
If fResult = 1
Return .T.
Else
Return .F.
Endif
Endif
Endproc
****************************************************
Procedure DeleteFtpFile
Lparameters lcRemoteFile
Local fResult
If This.OpenFtpConnection() && Open an FTP Handle
lcRemoteFile = lcRemoteFile + cNULL
fResult = FtpDeleteFile(This.nConnect_Handle, @lcRemoteFile)
This.GetExtendedError()
This.CloseFtpConnection()
If fResult = 1
Return .T.
Else
Return .F.
Endif
Endif
Endproc
****************************************************
Procedure RenameFtpFile
Lparameters lcOldFile, lcNewFile
Local fResult
If This.OpenFtpConnection() && Open an FTP Handle
lcOldFile = lcOldFile + cNULL
lcNewFile = lcNewFile + cNULL
fResult = FtpRenameFile(This.nConnect_Handle, @lcOldFile, @lcNewFile)
This.GetExtendedError()
This.CloseFtpConnection()
If fResult = 1
Return .T.
Else
Return .F.
Endif
Endif
Endproc
Procedure CreateFtpDirectory(lcNewDir)
*#************************************
Local fResult
If This.OpenFtpConnection() && Open an FTP Handle
lcNewDir= lcNewDir + cNULL
fResult = FtpCreateDirectory(This.nConnect_Handle, @lcNewDir)
* THIS.GetExtendedError()
This.CloseFtpConnection()
If fResult = 1
Return .T.
Else
Return .F.
Endif
Endif
Endproc
****************************************************
Procedure RemoveFtpDirectory
Lparameters lcNewDir
Local fResult
If This.OpenFtpConnection() && Open an FTP Handle
lcNewDir = lcNewDir + cNULL
fResult = FtpRemoveDirectory(This.nConnect_Handle, @lcNewDir)
This.GetExtendedError()
This.CloseFtpConnection()
If fResult = 1
Return .T.
Else
Return .F.
Endif
Endif
Endproc
Procedure ChangeFtpDirectory(lcNewDir)
*#************************************
Local fResult, lcTempDir, llResult
If This.OpenFtpConnection() && Open an FTP Handle
llResult = .F.
lcNewDir = lcNewDir + cNULL
lcTempDir = Space(MAX_PATH)
fResult = FtpSetCurrentDirectory(This.nConnect_Handle, @lcNewDir)
This.GetExtendedError()
If fResult = 1
fResult = FtpGetCurrentDirectory(This.nConnect_Handle, @lcTempDir, MAX_PATH)
This.GetExtendedError()
If fResult = 1
This.cCurrentDir = lcTempDir
llResult = .T.
Endif
Endif
This.CloseFtpConnection()
Return llResult
Endif
Endproc
Procedure GetFtpDirectory(lcDirectory)
*#************************************
Local fResult, lcTempDir
If This.OpenFtpConnection() && Open an FTP Handle
lcTempDir = Space(MAX_PATH)
fResult = FtpGetCurrentDirectory(This.nConnect_Handle, @lcTempDir, MAX_PATH)
This.GetExtendedError()
lcDirectory = Left(lcTempDir, At(cNULL, lcTempDir) - 1)
This.CloseFtpConnection()
If fResult = 1
Return .T.
Else
Return .F.
Endif
Endif
Endproc
****************************************************
Procedure GetFtpDirectoryArray
Lparameters laDirectory, lcMask
Local cStruct, llResult, lnCount, fResult, lffHandle
If This.OpenFtpConnection() && Open an FTP Handle
lcMask = lcMask + cNULL
* Dimension the array to store the directory
* [x, 1] = FileName
* [x, 2] = Alternate FileName
* [x, 3] = File Size
* [x, 4] = File Create Date
* [x, 5] = File Last Access Time
* [x, 6] = File Last Write Time
* [x, 7] = File Attributes
Dimension laDirectory [1, 7]
laDirectory [1, 1] = .F.
* This is for a FoxPro Quirk.
lcStruct = Space(319) && Allocate space for the returned structure
* Get the first file or find out if
lffHandle = FtpFindFirstFile(This.nConnect_Handle, @lcMask, @lcStruct, 0, 0)
This.GetExtendedError()
If lffHandle = 0 Or This.nResult_Code = ERROR_NO_MORE_FILES
This.CloseFtpConnection()
Return .F.
Endif
* Parse out First File Information
This.CrackFile(lcStruct, @laDirectory)
llResult = 1
Do While This.nResult_Code != ERROR_NO_MORE_FILES And llResult != 0
lcStruct = Space(319)
* Get next files
llResult = InternetFindNextFile(lffHandle, @lcStruct)
This.GetExtendedError()
* If we got good information, go ahead and parse it
If This.nResult_Code != ERROR_NO_MORE_FILES And llResult != 0
This.CrackFile(lcStruct, @laDirectory)
Endif
Enddo
This.CloseFtpConnection()
Else
Return .F. && Unable to get FTP Connection
Endif
Return .T.
Endproc
Procedure GetErrorCode(llShowMessage)
*#***********************************
Local lcMessage
If llShowMessage = .T.
* Build Error Message Here
lcMessage = "Error (" + Alltrim(Str(This.nResult_Code)) + ") - " + This.GetErrorText(This.nResult_Code)
If !Empty(This.cExtended_Message)
lcMessage = lcMessage + Chr(13) + Chr(13) + "Erro extendido - (" + Alltrim(Str(This.nExtended_Result)) + ") - " + This.cExtended_Message
Endif
Messagebox(lcMessage, 48, "FTP - Mensagem de erro.")
Endif
Return This.nResult_Code
Endproc
****************************************************
Procedure GetExtendedErrorCode
Return This.nExtended_Result
Endproc
****************************************************
Procedure GetExtendedErrorMsg
Return This.cExtended_Message
Endproc
****************************************************
Procedure CrackFile
Lparameters lcString, laDirectory
Local lcFileName, lcAlterName, lnSizeHigh, lnSizeLow, lnFileSize, ;
lcAttributes, lnArrayLen, lcTimeBuff, ;
ldCreateDate, ldAccessDate, ldWriteDate, laNewArray, lnResult
If Type('laDirectory[1, 1]') = 'L' && Array Has Not Been Filed
* Force Record size of 1
Dimension laDirectory [1, 7]
Else
* Expand Array
Dimension laDirectory [ALEN(laDirectory, 1) + 1, 7]
Endif
* Get new Array Position
lnArrayLen = Alen(laDirectory, 1)
lcFileName = Substr(lcString, 45, MAX_PATH)
lcAlterName = Right(lcString, 14)
lcFileName = Left(lcFileName, At(cNULL, lcFileName) - 1) && Copy out just the File Name Text
lcAlterName = Left(lcAlterName, At(cNULL, lcAlterName) - 1)
* Convert File Size DWORDs
lnSizeHigh = (Asc(Substr(lcString, 29, 1)) * BYTE_1) + ;
(Asc(Substr(lcString, 30, 1)) * BYTE_2) + ;
(Asc(Substr(lcString, 31, 1)) * BYTE_3) + ;
(Asc(Substr(lcString, 32, 1)) * BYTE_4)
lnSizeLow = (Asc(Substr(lcString, 33, 1)) * BYTE_1) + ;
(Asc(Substr(lcString, 34, 1)) * BYTE_2) + ;
(Asc(Substr(lcString, 35, 1)) * BYTE_3) + ;
(Asc(Substr(lcString, 36, 1)) * BYTE_4)
* Build File Size
lnFileSize = (lnSizeHigh * MAXDWORD) + lnSizeLow
* Convert File Date
* Get File Create DateTime
lcTimeBuff = Substr(lcString, 5, 8)
ldCreateDate = This.CrackDate(lcTimeBuff)
* Get File Create DateTime
lcTimeBuff = Substr(lcString, 13, 8)
ldAccessDate= This.CrackDate(lcTimeBuff)
* Get File Create DateTime
lcTimeBuff = Substr(lcString, 21, 8)
ldWriteDate= This.CrackDate(lcTimeBuff)
* Get File Attributes
lcAttributes = This.CrackAttributes(Left(lcString, 4))
laDirectory[lnArrayLen, 1] = Alltrim(lcFileName)
laDirectory[lnArrayLen, 2] = Alltrim(lcAlterName)
laDirectory[lnArrayLen, 3] = lnFileSize
laDirectory[lnArrayLen, 4] = ldCreateDate
laDirectory[lnArrayLen, 5] = ldAccessDate
laDirectory[lnArrayLen, 6] = ldWriteDate
laDirectory[lnArrayLen, 7] = lcAttributes
Return
Endproc
****************************************************
Procedure CrackDate
Lparameters lcOutBuffer
Local lcInBuffer, ldDateTime, fResult, lcBuild, ;
lnDay, lnMonth, lnYear, lnHour, lnMinute, lnSecond
lcInBuffer = Space(16)
fResult = FileTimeToSystemTime(@lcOutBuffer, @lcInBuffer)
This.GetExtendedError()
If fResult = 0 && Failed
ldDateTime = {^1901/01/01 00:00:01} && Default Time
Return ldDateTime
Endif
lnYear = Asc(Substr(lcInBuffer, 1, 1)) + (Asc(Substr(lcInBuffer, 2, 1)) * BYTE_2)
lnMonth = Asc(Substr(lcInBuffer, 3, 1)) + (Asc(Substr(lcInBuffer, 4, 1)) * BYTE_2)
lnDay = Asc(Substr(lcInBuffer, 7, 1)) + (Asc(Substr(lcInBuffer, 8, 1)) * BYTE_2)
lnHour = Asc(Substr(lcInBuffer, 9, 1)) + (Asc(Substr(lcInBuffer, 10, 1)) * BYTE_2)
lnMinute= Asc(Substr(lcInBuffer, 11, 1)) + (Asc(Substr(lcInBuffer, 12, 1)) * BYTE_2)
lnSecond= Asc(Substr(lcInBuffer, 13, 1)) + (Asc(Substr(lcInBuffer, 13, 1)) * BYTE_2)
lcBuild = "^" + Alltrim(Str(lnYear)) + '/' + Alltrim(Str(lnMonth)) + '/' + Alltrim(Str(lnDay)) + ' ' + ;
ALLTRIM(Str(lnHour)) + ':' + Alltrim(Str(lnMinute)) + ':' + Alltrim(Str(lnSecond))
ldDateTime = {&lcBuild}
Return ldDateTime
Endproc
****************************************************
Procedure CrackAttributes
Lparameters lcBuffer
Local lcAttributes, lnValue
lcAttributes = ''
lnValue = (Asc(Substr(lcBuffer, 1, 1)) * BYTE_1) + ;
(Asc(Substr(lcBuffer, 2, 1)) * BYTE_2) + ;
(Asc(Substr(lcBuffer, 3, 1)) * BYTE_3) + ;
(Asc(Substr(lcBuffer, 4, 1)) * BYTE_4)
Do Case
Case Bittest(lnValue, BIT_ATTRIBUTE_READONLY)
lcAttributes = lcAttributes + 'R'
Case Bittest(lnValue, BIT_ATTRIBUTE_HIDDEN)
lcAttributes = lcAttributes + 'H'
Case Bittest(lnValue, BIT_ATTRIBUTE_SYSTEM)
lcAttributes = lcAttributes + 'S'
Case Bittest(lnValue, BIT_ATTRIBUTE_DIRECTORY)
lcAttributes = lcAttributes + 'D'
Case Bittest(lnValue, BIT_ATTRIBUTE_ARCHIVE)
lcAttributes = lcAttributes + 'A'
Case Bittest(lnValue, BIT_ATTRIBUTE_NORMAL)
lcAttributes = lcAttributes + 'N'
Case Bittest(lnValue, BIT_ATTRIBUTE_TEMPORARY)
lcAttributes = lcAttributes + 'T'
Case Bittest(lnValue, BIT_ATTRIBUTE_COMPRESSED)
lcAttributes = lcAttributes + 'C'
Case Bittest(lnValue, BIT_ATTRIBUTE_OFFLINE)
lcAttributes = lcAttributes + 'O'
Endcase
Return lcAttributes
Endproc
Procedure GetExtendedError
*#************************
Local lcMessage, lnError, lcBuffer
This.nResult_Code = GetLastError()
lnError = 0
lcBuffer= Space(MAX_PATH)
InternetGetLastResponseInfo(lnError, @lcBuffer, MAX_PATH)
This.nExtended_Result = lnError
This.cExtended_Message= Left(lcBuffer, At(cNULL, lcBuffer) - 1)
Return
Endproc
****************************************************
Procedure GetErrorText
Lparameters lnError
Local lcMessage
Do Case
Case lnError = ERROR_INTERNET_OUT_OF_HANDLES
lcMessage = "ERROR_INTERNET_OUT_OF_HANDLES"
Case lnError = ERROR_INTERNET_TIMEOUT
lcMessage = "ERROR_INTERNET_TIMEOUT"
Case lnError = ERROR_INTERNET_EXTENDED_ERROR
lcMessage = "ERROR_INTERNET_EXTENDED_ERROR"
Case lnError = ERROR_INTERNET_INTERNAL_ERROR
lcMessage = "ERROR_INTERNET_INTERNAL_ERROR"
Case lnError = ERROR_INTERNET_INVALID_URL
lcMessage = "ERROR_INTERNET_INVALID_URL"
Case lnError = ERROR_INTERNET_UNRECOGNIZED_SCHEME
lcMessage = "ERROR_INTERNET_UNRECOGNIZED_SCHEME"
Case lnError = ERROR_INTERNET_NAME_NOT_RESOLVED
lcMessage = "ERROR_INTERNET_NAME_NOT_RESOLVED"
Case lnError = ERROR_INTERNET_PROTOCOL_NOT_FOUND
lcMessage = "ERROR_INTERNET_PROTOCOL_NOT_FOUND"
Case lnError = ERROR_INTERNET_INVALID_OPTION
lcMessage = "ERROR_INTERNET_INVALID_OPTION"
Case lnError = ERROR_INTERNET_BAD_OPTION_LENGTH
lcMessage = "ERROR_INTERNET_BAD_OPTION_LENGTH"
Case lnError = ERROR_INTERNET_OPTION_NOT_SETTABLE
lcMessage = "ERROR_INTERNET_OPTION_NOT_SETTABLE"
Case lnError = ERROR_INTERNET_SHUTDOWN
lcMessage = "ERROR_INTERNET_SHUTDOWN"
Case lnError = ERROR_INTERNET_INCORRECT_USER_NAME
lcMessage = "ERROR_INTERNET_INCORRECT_USER_NAME"
Case lnError = ERROR_INTERNET_INCORRECT_PASSWORD
lcMessage = "ERROR_INTERNET_INCORRECT_PASSWORD"
Case lnError = ERROR_INTERNET_LOGIN_FAILURE
lcMessage = "ERROR_INTERNET_LOGIN_FAILURE"
Case lnError = ERROR_INTERNET_INVALID_OPERATION
lcMessage = "ERROR_INTERNET_INVALID_OPERATION"
Case lnError = ERROR_INTERNET_OPERATION_CANCELLED
lcMessage = "ERROR_INTERNET_OPERATION_CANCELLED"
Case lnError = ERROR_INTERNET_INCORRECT_HANDLE_TYPE
lcMessage = "ERROR_INTERNET_INCORRECT_HANDLE_TYPE"
Case lnError = ERROR_INTERNET_INCORRECT_HANDLE_STATE
lcMessage = "ERROR_INTERNET_INCORRECT_HANDLE_STATE"
Case lnError = ERROR_INTERNET_NOT_PROXY_REQUEST
lcMessage = "ERROR_INTERNET_NOT_PROXY_REQUEST"
Case lnError = ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND
lcMessage = "ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND"
Case lnError = ERROR_INTERNET_BAD_REGISTRY_PARAMETER
lcMessage = "ERROR_INTERNET_BAD_REGISTRY_PARAMETER"
Case lnError = ERROR_INTERNET_NO_DIRECT_ACCESS
lcMessage = "ERROR_INTERNET_NO_DIRECT_ACCESS"
Case lnError = ERROR_INTERNET_NO_CONTEXT
lcMessage = "ERROR_INTERNET_NO_CONTEXT"
Case lnError = ERROR_INTERNET_NO_CALLBACK
lcMessage = "ERROR_INTERNET_NO_CALLBACK"
Case lnError = ERROR_INTERNET_REQUEST_PENDING
lcMessage = "ERROR_INTERNET_REQUEST_PENDING"
Case lnError = ERROR_INTERNET_INCORRECT_FORMAT
lcMessage = "ERROR_INTERNET_INCORRECT_FORMAT"
Case lnError = ERROR_INTERNET_ITEM_NOT_FOUND
lcMessage = "ERROR_INTERNET_ITEM_NOT_FOUND"
Case lnError = ERROR_INTERNET_CANNOT_CONNECT
lcMessage = "ERROR_INTERNET_CANNOT_CONNECT"
Case lnError = ERROR_INTERNET_CONNECTION_ABORTED
lcMessage = "ERROR_INTERNET_CONNECTION_ABORTED"
Case lnError = ERROR_INTERNET_CONNECTION_RESET
lcMessage = "ERROR_INTERNET_CONNECTION_RESET"
Case lnError = ERROR_INTERNET_FORCE_RETRY
lcMessage = "ERROR_INTERNET_FORCE_RETRY"
Case lnError = ERROR_INTERNET_INVALID_PROXY_REQUEST
lcMessage = "ERROR_INTERNET_INVALID_PROXY_REQUEST"
Case lnError = ERROR_INTERNET_NEED_UI
lcMessage = "ERROR_INTERNET_NEED_UI"
Case lnError = ERROR_INTERNET_HANDLE_EXISTS
lcMessage = "ERROR_INTERNET_HANDLE_EXISTS"
Case lnError = ERROR_INTERNET_SEC_CERT_DATE_INVALID
lcMessage = "ERROR_INTERNET_SEC_CERT_DATE_INVALID"
Case lnError = ERROR_INTERNET_SEC_CERT_CN_INVALID
lcMessage = "ERROR_INTERNET_SEC_CERT_CN_INVALID"
Case lnError = ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
lcMessage = "ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR"
Case lnError = ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
lcMessage = "ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR"
Case lnError = ERROR_INTERNET_MIXED_SECURITY
lcMessage = "ERROR_INTERNET_MIXED_SECURITY"
Case lnError = ERROR_INTERNET_CHG_POST_IS_NON_SECURE
lcMessage = "ERROR_INTERNET_CHG_POST_IS_NON_SECURE"
Case lnError = ERROR_INTERNET_POST_IS_NON_SECURE
lcMessage = "ERROR_INTERNET_POST_IS_NON_SECURE"
Case lnError = ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
lcMessage = "ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED"
Case lnError = ERROR_INTERNET_INVALID_CA
lcMessage = "ERROR_INTERNET_INVALID_CA"
Case lnError = ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP
lcMessage = "ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP"
Case lnError = ERROR_INTERNET_ASYNC_THREAD_FAILED
lcMessage = "ERROR_INTERNET_ASYNC_THREAD_FAILED"
Case lnError = ERROR_INTERNET_REDIRECT_SCHEME_CHANGE
lcMessage = "ERROR_INTERNET_REDIRECT_SCHEME_CHANGE"
Case lnError = ERROR_INTERNET_DIALOG_PENDING
lcMessage = "ERROR_INTERNET_DIALOG_PENDING"
Case lnError = ERROR_INTERNET_RETRY_DIALOG
lcMessage = "ERROR_INTERNET_RETRY_DIALOG"
Case lnError = ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
lcMessage = "ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR"
Case lnError = ERROR_INTERNET_INSERT_CDROM
lcMessage = "ERROR_INTERNET_INSERT_CDROM"
Case lnError = FTP_TRANSFER_IN_PROGRESS
lcMessage = "FTP_TRANSFER_IN_PROGRESS"
Case lnError = FTP_DROPPED
lcMessage = "FTP_DROPPED"
Case lnError = FTP_NO_PASSIVE_MODE
lcMessage = "FTP_NO_PASSIVE_MODE"
Case lnError = ERROR_INTERNET_SECURITY_CHANNEL_ERROR
lcMessage = "ERROR_INTERNET_SECURITY_CHANNEL_ERROR"
Case lnError = ERROR_INTERNET_UNABLE_TO_CACHE_FILE
lcMessage = "ERROR_INTERNET_UNABLE_TO_CACHE_FILE"
Case lnError = ERROR_INTERNET_TCPIP_NOT_INSTALLED
lcMessage = "ERROR_INTERNET_TCPIP_NOT_INSTALLED"
Case lnError = ERROR_INTERNET_DISCONNECTED
lcMessage = "ERROR_INTERNET_DISCONNECTED"
Case lnError = ERROR_INTERNET_SERVER_UNREACHABLE
lcMessage = "ERROR_INTERNET_SERVER_UNREACHABLE"
Case lnError = ERROR_INTERNET_PROXY_SERVER_UNREACHABLE
lcMessage = "ERROR_INTERNET_PROXY_SERVER_UNREACHABLE"
Case lnError = ERROR_INTERNET_BAD_AUTO_PROXY_script
lcMessage = "ERROR_INTERNET_BAD_AUTO_PROXY_script"
Case lnError = ERROR_INTERNET_UNABLE_TO_DOWNLOAD_script
lcMessage = "ERROR_INTERNET_UNABLE_TO_DOWNLOAD_script"
Case lnError = ERROR_INTERNET_SEC_INVALID_CERT
lcMessage = "ERROR_INTERNET_SEC_INVALID_CERT"
Case lnError = ERROR_INTERNET_SEC_CERT_REVOKED
lcMessage = "ERROR_INTERNET_SEC_CERT_REVOKED"
Case lnError = ERROR_NO_MORE_FILES
lcMessage = "ERROR_NO_MORE_FILES"
Case lnError = ERROR_INVALID_HANDLE
lcMessage = "ERROR_INVALID_HANDLE"
Case lnError = ERROR_FILE_NOT_FOUND
lcMessage = "ERROR_FILE_NOT_FOUND"
Case lnError = ERROR_PATH_NOT_FOUND
lcMessage = "ERROR_PATH_NOT_FOUND"
Case lnError = ERROR_ACCESS_DENIED
lcMessage = "ERROR_ACCESS_DENIED"
Case lnError = ERROR_FILE_EXISTS
lcMessage = "ERROR_FILE_EXISTS"
Case lnError = ERROR_INVALID_PARAMETER
lcMessage = "ERROR_INVALID_PARAMETER"
Otherwise
lcMessage = "Unknown Error Message"
Endcase
Return lcMessage
Endproc
Enddefine && End Class Define

mfelis- Participa Bastante

Re: Saber Total de KB já Baixados pelo FTP
[Você precisa estar registrado e conectado para ver este link.]
Abaixe o arquivo "bbDownLoadURL" ele já faz isso para você e muito simples...
Abaixo um código como exemplo
Obs:
- No código em negrito a linha "liDownLoaded=DownLoad..." é uma linha só, caso de erro é só colocar na mesma linha;
- "seuarquivo.exe" é o nome que você quiser, coloquei .exe só como exemplo;
- "THISFORM.FeedBack" é um método criado no form, pode ser uma variável.
Qualquer dúvida sobre a rotina pode escrever.
Abaixe o arquivo "bbDownLoadURL" ele já faz isso para você e muito simples...
Abaixo um código como exemplo
Obs:
- No código em negrito a linha "liDownLoaded=DownLoad..." é uma linha só, caso de erro é só colocar na mesma linha;
- "seuarquivo.exe" é o nome que você quiser, coloquei .exe só como exemplo;
- "THISFORM.FeedBack" é um método criado no form, pode ser uma variável.
Qualquer dúvida sobre a rotina pode escrever.
- Código:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
**************************************************
*-- Form: form1 (e:\developvf90\teste e exemplos\bbdownloadurl\download.scx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 05/14/08 06:49:07 PM
*
DEFINE CLASS form1 AS form
Top = 0
Left = 0
Height = 152
Width = 509
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 114, ;
Left = 407, ;
Height = 27, ;
Width = 84, ;
Caption = "Command1", ;
Name = "Command1"
ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
Caption = "Tamanho Total (bytes):", ;
Height = 17, ;
Left = 73, ;
Top = 21, ;
Width = 128, ;
Name = "Label1"
ADD OBJECT label2 AS label WITH ;
AutoSize = .T., ;
Caption = "Bytes recebidos:", ;
Height = 17, ;
Left = 74, ;
Top = 52, ;
Width = 93, ;
Name = "Label2"
ADD OBJECT lbltotal AS label WITH ;
AutoSize = .T., ;
Caption = "XXX", ;
Height = 17, ;
Left = 207, ;
Top = 23, ;
Width = 23, ;
Name = "lblTotal"
ADD OBJECT lblrecebido AS label WITH ;
AutoSize = .T., ;
Caption = "YYY", ;
Height = 17, ;
Left = 207, ;
Top = 54, ;
Width = 23, ;
Name = "lblRecebido"
PROCEDURE feedback
LPARAMETERS tiAll, tiCount
THISFORM.lblTotal.Caption = TRANSFORM(tiAll)
THISFORM.lblRecebido.Caption = TRANSFORM(tiCount)
RETURN .t.
ENDPROC
PROCEDURE command1.Click
set library to bbDownLoadURL.fll
lcURL="http://www.suapagina.com.br/seuarquivo.exe"
liDownLoaded=DownLoadURL(lcURL,"c:\Temp\seuarquivo.exe","THISFORM.FeedBack",100,.t.)
ENDPROC
ENDDEFINE
*
*-- EndDefine: form1
Última edição por Marcos Guedes em 13/3/2010, 00:10, editado 1 vezes (Razão : Remoção da formatação de texto: [b] e [/b])
lardecristo- Participante Regular

Re: Saber Total de KB já Baixados pelo FTP
boa hein cristo
valeu
e ai mfelis
podemos matar o topico?
resolvido teu problema?
valeu
e ai mfelis
podemos matar o topico?
resolvido teu problema?
_________________
A lingua é o chicote do corpo! Minhas feridas ainda doem!

hugo- Usuário 5 Estrelas

Re: Saber Total de KB já Baixados pelo FTP
Parabéns pelo desempenho, lardecristo!
_________________
Marcos Guedes - Programador e desenvolvedor Web.
Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

Marcos Guedes- Webmaster

Re: Saber Total de KB já Baixados pelo FTP
Não Entendi o Código.Como irei saber quando porcento já a Minha Função FTP do Wininet Baixou.Como Encrementar Está Função no Meu PRG FTP?
A Minha CLasse FTP é uma DLL que Chamo de FTPNET
A Minha CLasse FTP é uma DLL que Chamo de FTPNET

mfelis- Participa Bastante

Re: Saber Total de KB já Baixados pelo FTP
mfelis, para o que queres, deverás estudar a rotina pois em algum local do código a transferência é realizada byte a byte.
encontrando este ponto, então você adiciona a forma como desejas exibir os valores para o usuário.

encontrando este ponto, então você adiciona a forma como desejas exibir os valores para o usuário.

_________________
Marcos Guedes - Programador e desenvolvedor Web.
Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

Marcos Guedes- Webmaster

Re: Saber Total de KB já Baixados pelo FTP
Bom, o código não utiliza a sua rotina, ela utiliza a FLL que falei para baixar, a mesmo já faz todo o processo, traz o tamanho do arquivo e quanto baixou do mesmo, experimente o código e veja o resultado.
Lembrando o mesmo precisa conter o endereço do arquivo que você deseja baixar e também o nome da pasta e do arquivo para ser salvo no equipamento.
Qualquer coisa post novamente.
Lembrando o mesmo precisa conter o endereço do arquivo que você deseja baixar e também o nome da pasta e do arquivo para ser salvo no equipamento.
Qualquer coisa post novamente.
lardecristo- Participante Regular

Re: Saber Total de KB já Baixados pelo FTP
Sim.Claro
Queria Saber se Esta Rotina Baixa os Arquivos
Queria Saber se Esta Rotina Baixa os Arquivos

mfelis- Participa Bastante

Re: Saber Total de KB já Baixados pelo FTP
Sim, baixa o arquivo, por favor pegue o código que deixei lá em cima e TESTE, e leia o post que tem algumas explicações.
Qualquer coisa post novamente.
Qualquer coisa post novamente.
lardecristo- Participante Regular

Re: Saber Total de KB já Baixados pelo FTP
Já Fiz os Testes e Problema é que preciso baixar por FTP assim está FLL não Permite Autenticação

mfelis- Participa Bastante

Re: Saber Total de KB já Baixados pelo FTP
Consegui adaptar a rotina de FTP para exibir os kb baixados, Marcelo?
_________________
Marcos Guedes - Programador e desenvolvedor Web.
Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

Marcos Guedes- Webmaster

Re: Saber Total de KB já Baixados pelo FTP
não resolvi mas achei um jeito de não paresser que está travado

mfelis- Participa Bastante

Re: Saber Total de KB já Baixados pelo FTP
Utilizando outro executável?mfelis escreveu:não resolvi mas achei um jeito de não paresser que está travado
_________________
Marcos Guedes - Programador e desenvolvedor Web.
Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

Marcos Guedes- Webmaster

Página 1 de 2 • 1, 2 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum




» Gerador randomico de chave/senha VFP
» Help do VFP 9 desapareceu
» Acessos no Programação Brasil
» Niver do Alceu
» Report com comandos de impressão @ SAY
» VFP Studio
» Emulacao de MAC em PC
» Imagem
» Formação em produção de games 3D no Rio de Janeiro
» Trazer para frente uma aplicação em execução
» PictureBox com fundo transparente
» Report so imprime primeiro registro
» IE x VFP
» Aplicativos para Dispositivos moveis
» Problemas com Form MDI
» Dataset ou Datatable
» Desabafo de um idoso!
» Select criando cursor apresenta erro
» Comandos alterados de DOS para Visual