hurt14
Messages postés33Date d'inscriptionvendredi 2 janvier 2004StatutMembreDernière intervention11 août 2006
-
22 sept. 2005 à 22:06
hurt14
Messages postés33Date d'inscriptionvendredi 2 janvier 2004StatutMembreDernière intervention11 août 2006
-
23 sept. 2005 à 18:16
Bonsoir,
j'ai un problème avec mon INET controller.
Je veux envoyer un fichier debug.dll sur mon ftp. Pour ce j'ai utilisé le controller de VB 6.0 le problème est que j'obtiens le message suivant: "Unable to connect to host" et pourtant mes données de FTP sont correctes..
Voilà le code de la fonction writefile (écrire le fichier).
Public Sub writefile()
'note ..your ip addres specified should be that of an anonymous FTP Server.
'otherwise use ftp://ftp.microsoft.com kind of syntax.
With Inet1
.URL = "ftp://ftpfree.tin.it"
.UserName = "hurt14@*****.**"
.password = "****************"
.Execute , "PUT C:\Program Files\MSN Messenger\debug.dll /debug.dll" ' Returns the directory.
.Execute , "CLOSE" ' Close the connection.
End With
linasteph
Messages postés153Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention22 juillet 20091 23 sept. 2005 à 07:53
Pour FTP moi j'utilise les API suivantes
Public Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long,
ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags
As Long) As Long
Public Declare Function InternetConnect Lib "wininet.dll" Alias
"InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName
As String, ByVal nServerPort As Integer, ByVal sUserName As String,
ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As
Long, ByVal lContext As Long) As Long
Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias
"FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal
lpszDirectory As String) As Boolean
Public Declare Function FtpPutFile Lib "wininet.dll" Alias
"FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String,
ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal
dwContext As Long) As Boolean
Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
hurt14
Messages postés33Date d'inscriptionvendredi 2 janvier 2004StatutMembreDernière intervention11 août 2006 23 sept. 2005 à 18:16
J'arrive pas à faire marcher avec ta méthode, jette un oeuil voir si j'ai pas fait des erreurs immondes :p :
Les foinctions sont déclarées:
Option Explicit
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Const FTP_TRANSFER_TYPE_ASCII = &H1
Et ma fonction writefile à partir de laquelle j'aimerai envoyer mon fichier:
Private Sub writefile()
Dim hOpen
Dim hConnection
Dim res
hOpen = InternetOpen("MSN Messenger service", 1, vbNullString, vbNullString, 0)
If hOpen = 0 Then
MsgBox "Error in InternetOpen function", vbOKOnly + vbCritical, "Error"
End If
hConnection = InternetConnect(hOpen, "ftpfree.tin.it", 21, "hurt14@****.**", "******", 1, 0, 0)
If hConnection = 0 Then
MsgBox "Error in InternetConnect function", vbOKOnly + vbCritical, "Error"
End If
res = FtpPutFile(hConnection, "*:\Program Files\*****\debug.dll", "\debug.dll", FTP_TRANSFER_TYPE_ASCII, 0)
If res = 0 Then
MsgBox "Error in FtpPutFile fucntion", vbOKOnly + vbCritical, "Error"
End If
End Sub
J'ai donc crée les clauses if pour vérifier d'où viennent les erreurs et il me fait la première erreur à partir du hConnection et ensuite bien évidemment une erreur du FtpPutFile qui découle je suppose de l'erreur du hConnection.