lex1111
Messages postés220Date d'inscriptionjeudi 30 mars 2006StatutMembreDernière intervention26 octobre 2007
-
17 déc. 2006 à 23:24
cs_Willi
Messages postés2375Date d'inscriptionjeudi 12 juillet 2001StatutModérateurDernière intervention15 décembre 2018
-
17 déc. 2006 à 23:55
Bonjour, j'essaye d'utiliser les api suivantes dans mon prog en VB2005 pour recuperer le code source html d'une page web :
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 InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal sUrl As String, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, ByVal lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000 ' Pas d'écriture en cache
Private Function GetUrlFile(ByVal stUrl As String) As String
'Récupère le contenu d'une page/d'un fichier sur internet
Dim lgInternet As Long, lgSession As Long
Dim stBuf As String
Dim inRes As Integer
Dim lgRet As Long
Dim stTotal As String
Try
lgSession = InternetOpen("VBTagEdit", 1, vbNullString, vbNullString, 0)
stTotal = vbNullString
' Récupère un pointeur vers la connexion internet courante
If lgSession Then
' Récupère un pointeur vers l'URL
lgInternet = InternetOpenUrl(lgSession, stUrl, vbNullString, 0, INTERNET_FLAG_NO_CACHE_WRITE, 0)
If lgInternet Then
Do
System.Windows.Forms.Application.DoEvents()
' Lecture de la page dans le buffer (par bloc de 1024)
inRes = InternetReadFile(lgInternet, stBuf, 1024, lgRet)
stTotal = stTotal & Mid$(stBuf, 1, lgRet)
Loop While (lgRet <> 0)
End If
' Libération du pointeur
inRes = InternetCloseHandle(lgInternet)
End If
' Retourne le résultat
GetUrlFile = stTotal
'en cas d'erreur
Catch ex As Exception
GetUrlFile = ""
End Try
End Function
j'ai l'erreure suivante :
L'Assistant Débogage managé 'PInvokeStackImbalance' a détecté un problème dans 'D:\programmation\SOURCES MOI\HDDIVX\HD_DIVX v3.0 vb.net\HD-Divx\bin\Debug\HD-Divx.vshost.exe'.
Informations supplémentaires : Un appel à la fonction PInvoke 'HD-Divx!HD_Divx.Frm_accueil::InternetOpenUrl' a déséquilibré la pile. Cela peut se produire, car la signature PInvoke managée ne correspond pas à la signature cible non managée. Vérifiez que la convention d'appel et les paramètres de la signature PInvoke correspondent à la signature non managée cible.
J'ai bien lu ce post, mais je n'arrive pas à appliquer la solution à mon pb...