Coment fonctionne Inet :-(:-(:-(:-(:-(:-(:-(:-(:-(!!!!!!!!!!!!

Résolu
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 - 17 août 2004 à 18:14
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 - 18 août 2004 à 09:47
Slt tout le monde!
j'aimerai comprendre le fonctionnement de Inet(j'y connai rien,un truc pas trop dur si possible)
merci!
VirusMan :-p

2 réponses

pcpunch Messages postés 1243 Date d'inscription mardi 7 mai 2002 Statut Membre Dernière intervention 18 février 2019 5
17 août 2004 à 20:54
Inet sert a faire des opérations sur un ftp :Lister, telecharger, uploader, renomer, etc....(Commande Execute), ou mm a recuperer le code src d'une page web ou txt, etc....

Voici un exemple pour se connecter a un ftp, tiré de Msdn :

Protocol Property (Internet Transfer Control) Example
This example shows how you can set the Protocol property to specify what transfer protocol the Internet Transfer Control will use. In the example, the URL property is initially set to an address without a protocol. By setting the Protocol property to icFTP, you not only specify the transfer protocol, but change the URL property as well, as the MsgBox call shows. Conversely, if you change the URL property and include a protocol (here, http://), the Protocol property is updated automatically.

Private Sub showProtocol_Click()
   Inet1.URL = "example.microsoft.com"
   Inet1.Protocol = icFTP   ' Sets protocol explicitly
   ' MsgBox will display "ftp://example.microsoft.com"
   MsgBox "URL = " & Inet1.URL

   ' Changes URL by including a protocol directly in URL
   Inet1.URL = "http://example.microsoft.com"
   ' MsgBox now shows protocol as 4 (icFTP)   MsgBox "URL " & Inet1.URL & ", Protocol " & Inet1.Protocol
End Sub


PS: Sachant que pour un ftp perso :
Inet1.url="ftp://user:pass@serveur"
Toujours tiré de Msdn qq exemple de la méthode execute :

Execute Method Example
The example shows a series of common FTP operations using the Execute method. The example assumes that three TextBox controls exist on the form. The first, txtURL contains the URL of the FTP server. The second, txtRemotePath, contains additional information needed by the particular command. The third, txtResponse, contains the response of the server.

Private Sub cmdChangeDirectory_Click()
' Change directory to txtRemotePath.
Inet1.Execute txtURL.Text, "CD " & _
txtRemotePath.Text
End Sub

Private Sub cmdDELETE_Click()
' Delete the directory in txtRemotePath.
Inet1.Execute txtURL.Text, "DELETE " & _
txtRemotePath.Text
End Sub

Private Sub cmdDIR_Click()
Inet1.Execute txtURL.Text, "DIR FindThis.txt"
End Sub

Private Sub cmdGET_Click()
Inet1.Execute txtURL.Text, _
"GET GetThis.txt C:\MyDocuments\GotThis.txt"
End Sub

Private Sub cmdSEND_Click()
Inet1.Execute txtURL.Text, _
"SEND C:\MyDocuments\Send.txt SentDocs\Sent.txt"
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
' Retrieve server response using the GetChunk
' method when State = 12.

Dim vtData As Variant ' Data variable.
Select Case State
' ... Other cases not shown.
Case icError ' 11
' In case of error, return ResponseCode and
' ResponseInfo.
vtData = Inet1.ResponseCode & ":" & _
Inet1.ResponseInfo
Case icResponseCompleted ' 12
Dim vtData As Variant
Dim strData As String
Dim bDone As Boolean: bDone = False

' Get first chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents

Do While Not bDone
strData = strData & vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents

If Len(vtData) = 0 Then
bDone = True
End If
Loop
txtData.Text = strData
End Select

End Sub

Pour ce qui est de récuperer le code src d'un page Html ou le contenu d'un fichier txt par exemple :

<code>
Dim LaSource as string
LaSource=inet1.openurl "http://www.url.com/fichier.txt"


Ps: Inet est assez difficile a utiliser, et en plus je le trouve assez instable, mais pour un soft perso c'est une bonne solution!!!

Pour plus de sureté, il vaut mieux utiliser winsock!!! mais ce n'est que mon avis!!!!

++
3
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 1
18 août 2004 à 09:47
Merci beaucoup j'ai tout compris(parceque les sources a ce sujet ne sont generalement pas aussis detaillées et claires)
VirusMan :-p
0
Rejoignez-nous