par Michael DELIQUE » 15 Juil 2009 à 13:07
- Code : Tout sélectionner
Function ReadHTTP_API(wURL As String) As String
Dim nbHandle As Long
Dim nbHandleSession As Long
Dim Header As String
Dim Buffer As String * 1024
Dim nbByteCount As Long
%REM
Permet de lire le code HTML de l'url passé en parametre (si cette url ests ur un server domino
Declare Private Function InternetReadFile Lib "wininet.dll" (Byval hInet As Long, Byval data As String, Byval length As Long, lengthread As Long) As Integer
Declare Private Function InternetCloseHandle Lib "wininet.dll" Alias "InternetCloseHandle" (Byval hInet As Long) As Long
Declare Private 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
Declare Private Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (Byval hOpen As Long, Byval sUrl As String, Byval sHeaders As String, Byval lLength As Long, Byval lFlags As Long, Byval lContext As Long) As Long
%END REM
On Error Goto ErreurHandle
nbHandle=0
nbHandleSession = 0
ReadHTTP_API = ""
nbHandle = InternetOpen("Lotus Notes", 1 , Chr(0), Chr(0), 0)
If nbHandle = 0 Then
Error 9999, "Could not get handle to WININET.DLL."
Exit Function
End If
If nbHandleSession <> 0 Then
Call InternetCloseHandle(nbHandleSession)
End If
nbHandleSession = InternetOpenUrl(nbHandle, wURL, Header, Len(Header), &H80000000, 0)
'Print Me.nbHandleSession
Do
Buffer = ""
If InternetReadFile( nbHandleSession, Buffer, Len(Buffer), nbByteCount) Then
ReadHTTP_API = ReadHTTP_API + Left(Buffer, nbByteCount)
End If
Loop While nbByteCount > 0
If nbHandle <> 0 Then
Call InternetCloseHandle(nbHandle)
End If
If nbHandleSession <> 0 Then
Call InternetCloseHandle(nbHandleSession)
End If
Exit Function
ErreurHandle:
Msgbox "("+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
ReadHTTP_API = ""
Exit Function
End Function
Cordialement
Michael (SMS-Phobique)
----------------------------
"La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi."
Albert EINSTEIN