Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Porque esto no me funciona???
Message
From
07/07/2003 17:30:13
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Porque esto no me funciona???
Miscellaneous
Thread ID:
00807678
Message ID:
00807678
Views:
55
esto me lo encontre por ahi en la internet y queria probar a que tal, pero no me baja el archivo y no se porque, casi todos los ejemplos que he visto son iguales, porque este no funciona no veo la razon???



DECLARE INTEGER InternetOpen IN wininet;
STRING sAgent, INTEGER lAccessType, STRING sProxyName,;
STRING sProxyBypass, STRING lFlags

DECLARE INTEGER InternetCloseHandle IN wininet INTEGER hInet

DECLARE INTEGER InternetConnect IN wininet.DLL;
INTEGER hInternetSession,;
STRING lcHost,;
INTEGER nServerPort,;
STRING lcUser,;
STRING lcPassword,;
INTEGER lService,;
INTEGER lFlags,;
INTEGER lContext

DECLARE INTEGER FtpGetFile IN wininet;
INTEGER hftpSession, ;
STRING lcRemoteFile,;
STRING lcNewFile, ;
INTEGER fFailIfExists,;
INTEGER dwFlagsAndAttributes,;
INTEGER dwFlags, ;
INTEGER dwContext
***********************************************************

lcHost = ALLTRIM("10.10.1.200")
lcUser = ALLTRIM("usser")
lcPwd = ALLTRIM("pass")
lcRemoteFile = ALLTRIM("\Actualizaciones\traspasos\traspasos.exe")
lcNewFile = ALLTRIM("C:\alexis\traspasos.exe")

sAgent = "vfp"

sProxyName = CHR(0) &&... no proxy
sProxyBypass = CHR(0) &&... nothing to bypass
lFlags = 0 &&... no flags used

*... initialize access to Inet functions
hOpen = InternetOpen (sAgent, 1,;
sProxyName, sProxyBypass, lFlags)

IF hOpen = 0
WAIT WINDOW "Unable to get access to WinInet.Dll" TIMEOUT 2
RETURN
ENDIF

*... The first '0' says use the default port, usually 21.
hftpSession = InternetConnect (hOpen, lcHost,;
0, lcUser, lcPwd, 1, 0, 0) &&... 1 = ftp protocol

IF hftpSession = 0
*... close access to Inet functions and exit
= InternetCloseHandle (hOpen)
WAIT WINDOW "Unable to connect to " + lcHost + '.' TIMEOUT 2
RETURN
ELSE
WAIT WINDOW "Connected to " + lcHost + " as: [" + lcUser + "]"
ENDIF

*... 0 to automatically overwrite file
*... 1 to fail if file already exists
fFailIfExists = 0
dwContext = 0 &&... used for callback

WAIT WINDOW 'Transfering ' + lcRemoteFile + ' to ' + lcNewFile + '...'
*!* lnResult = FtpGetFile (hftpSession, lcRemoteFile, lcNewFile,;
*!* fFailIfExists, 128, 1,;
*!* dwContext)





#DEFINE FILE_ATTRIBUTE_NORMAL 128
#DEFINE FTP_TRANSFER_TYPE_ASCII 1
#DEFINE FTP_TRANSFER_TYPE_BINARY 2
*** Declaración de funciones
WAIT WIND "Recibiendo el fichero" NOWAIT
lnResult = FtpGetFile( ;
hftpSession, ;
"/Actualizaciones/traspasos/traspasos.exe", "traspasos.exe", 0, ;
FILE_ATTRIBUTE_NORMAL, ;
FTP_TRANSFER_TYPE_ASCII, ;
0 )


************************************************************
*... 128 = #define FILE_ATTRIBUTE_NORMAL 0x00000080
*... See CreateFile for other attributes

* close handles
= InternetCloseHandle (hftpSession)
= InternetCloseHandle (hOpen)

IF lnResult = 1
*... successful download, do what you want here
WAIT WINDOW 'Completed.' TIMEOUT 1
* MODI FILE (lcNewFile)
ELSE
WAIT WINDOW "No se Puede bajar el Archivo" TIMEOUT 2
ENDIF

RETURN
El Hombre que dice
"No Puede Hacerse",
será sorprendido por
"Alguien que lo Haga"
Reply
Map
View

Click here to load this message in the networking platform