Hallo Ihr Experten
Ich habe in VB 6.0 mit den API Funktionen InternetOpen, InternetConnect und HttpOpenRequest eine Funktion geschrieben die Daten eine Webseite mit Post Requsts ausliest und dann das Ergebnis in einen String speichert.
Die Funktion funktioniert auch recht Gut solange ich nicht über einen nicht anonymen Proxy laufe bzw beim IE ein nicht anonymer Proxy zwingend erforderlich ist.
Kamm mir jemand Informationen liefern wie ich die InternetOpen, InternetConnect und HttpOpenRequest Funktionen Proxy tauglich mache und zwar so dass nur ein Username und ein Passwort über die Oberfläche eingegeben werden muß.
Schon im Voraus bedanke ich mich für jede Information.
Code der Funktion:
Public Function Upload\_date\_per\_Html(m\_Servername As String, \_
m\_Url As String, ByRef m\_parameter As Http\_Post\_Parameter, \_
ByRef m\_ptrResult As String, Optional ByVal m\_Proxy\_Name As String = vbNullString, \_
Optional ByVal m\_Proxy\_Password As String = vbNullString)
Dim m\_Internet\_open As Long
Dim m\_Internet\_Connection As Long
Dim m\_Http\_open\_requests As Long
Dim m\_number\_of\_Bytes\_read As Long
Dim m\_Ret As Boolean
Dim m\_do\_loop As Boolean
Dim m\_read\_buffer As String \* 2048
Dim m\_post\_data As String
Dim m\_Header As String
m\_Internet\_open = 0
m\_Internet\_Connection = 0
m\_Http\_open\_requests = 0
If m\_Proxy\_Name = vbNullString Then
m\_Internet\_open = InternetOpen(App.EXEName, INTERNET\_OPEN\_TYPE\_PRECONFIG, vbNullString, vbNullString, 0)
Else
m\_Internet\_open = InternetOpen(App.EXEName, INTERNET\_OPEN\_TYPE\_PROXY, m\_Proxy\_Name, m\_Proxy\_Password, 0)
End If
If m\_Internet\_open 0 Then
m\_Internet\_Connection = InternetConnect(m\_Internet\_open, m\_Servername, INTERNET\_DEFAULT\_HTTP\_PORT, vbNullString, "HTTP/1.0", INTERNET\_SERVICE\_HTTP, 0, 0)
If m\_Internet\_Connection 0 Then
m\_Http\_open\_requests = HttpOpenRequest(m\_Internet\_Connection, "POST", m\_Url, "HTTP/1.0", vbNullString, 0, INTERNET\_FLAG\_RELOAD, 0)
If m\_Http\_open\_requests 0 Then
m\_Header = "Content-Type: multipart/form-data, boundary=AaB03x" & vbCrLf
m\_Ret = HttpAddRequestHeaders(m\_Http\_open\_requests, m\_Header, Len(m\_Header), HTTP\_ADDREQ\_FLAG\_REPLACE Or HTTP\_ADDREQ\_FLAG\_ADD)
m\_post\_data = m\_parameter.get\_Post\_string()
m\_Ret = HttpSendRequest(m\_Http\_open\_requests, vbNullString, 0, m\_post\_data, Len(m\_post\_data))
m\_ptrResult = ""
Do
m\_read\_buffer = vbNullString
m\_do\_loop = InternetReadFile(m\_Http\_open\_requests, m\_read\_buffer, Len(m\_read\_buffer), m\_number\_of\_Bytes\_read)
m\_ptrResult = m\_ptrResult & Left(m\_read\_buffer, m\_number\_of\_Bytes\_read)
If Not CBool(m\_number\_of\_Bytes\_read) Or Not m\_do\_loop Then Exit Do
Loop
Upload\_date\_per\_Html = True
Else
If m\_Internet\_open 0 Then
Call InternetCloseHandle(m\_Internet\_open)
End If
If m\_Internet\_Connection 0 Then
Call InternetCloseHandle(m\_Internet\_Connection)
End If
If m\_Http\_open\_requests 0 Then
Call InternetCloseHandle(m\_Http\_open\_requests)
End If
Upload\_date\_per\_Html = False
End If
Else
If m\_Internet\_open 0 Then
Call InternetCloseHandle(m\_Internet\_open)
End If
If m\_Internet\_Connection 0 Then
Call InternetCloseHandle(m\_Internet\_Connection)
End If
Upload\_date\_per\_Html = False
End If
Else
If hInternetOpen 0 Then
Call InternetCloseHandle(m\_Internet\_open)
End If
Upload\_date\_per\_Html = False
End If
End Function