Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

InternetOpen and PPC 2003 in eVb

4 réponses
Avatar
Patrice Pennetier
Hello everyone,
I have an apps that works well in PPC 2002 and running it from PPC 2003 is
perfect except for the following : the handle returned from InternetOpenUrl
is 0 in PPC 2003 and is 13356932 in PPC 2002.
It's like the internet function is not working ?
If I use XMLObjects, it works, so I know the connection is alive, but I need
Wininet functions to read binary files.
Anybody any clues ? Am I using wrong parameters ?
Thanks
Pennetier@hotmail.com
Here is the code :

'*********************
Option Explicit
Declare Function InternetOpen Lib "wininet" Alias "InternetOpenW" ( _
ByVal sAgent As String, _
ByVal lAccessType As Long, _
ByVal sProxyName As String, _
ByVal sProxyBypass As String, _
ByVal lFlags As Long) _
As Long
Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlW" ( _
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
Declare Function InternetReadFile Lib "wininet" ( _
ByVal hFile As Long, _
ByVal sBuffer As String, _
ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) _
As Integer
Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As
Integer
Declare Function MultiByteToWideChar Lib "Coredll.DLL" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As String, _
ByVal cchWideChar As Long) _
As Long

Const CP_ACP = 0
Const MB_PRECOMPOSED = &H1
Const BUFFER_LEN = 256
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Const INTERNET_SERVICE_HTTP = 3
Public Function LogMe(sUrl As String) As String
Dim sBuffer As String
Dim sBuffer2 As String
Dim Buffer_Data As String
Dim hOpen As Long
Dim hFile As Long
Dim Ret As Long
Dim Len_html As Long
Dim je_sais_pas As Long
Dim Buff As Integer
Dim MyError As String
'On Error Resume Next
Buff = 2000
sBuffer = Space(Buff): Buffer_Data = Space(Buff)
hOpen = InternetOpen("test", INTERNET_OPEN_TYPE_DIRECT, vbNullString,
vbNullString, 0)
MsgBox hOpen
If hOpen <> 0 Then
hFile = InternetOpenUrl(hOpen, sUrl, Buffer_Data, Len_html,
INTERNET_FLAG_RELOAD, je_sais_pas)
MsgBox hFile 'here is where I get something in PPC2002 and 0 in PPC2003
???????
If hFile <> 0 Then
Do
InternetReadFile hFile, sBuffer, Buff, Ret
sBuffer2 = sBuffer2 & Mid(sBuffer, 1, Ret)
Loop While Ret <> 0 And Len(sBuffer2) < Buff
InternetCloseHandle hFile
End If
InternetCloseHandle hOpen
End If
MsgBox sBuffer2
MultiByteToWideChar CP_ACP, MB_PRECOMPOSED, sBuffer2, -1, Buffer_Data, Buff
GetData = Buffer_Data
Set sBuffer = Nothing
Set sBuffer2 = Nothing
Set Buffer_Data = Nothing
Set hOpen = Nothing
Set hFile = Nothing
Set Ret = Nothing
Set Len_html = Nothing
Set je_sais_pas = Nothing
End Function

4 réponses

Avatar
Patrice Pennetier
Hi there,
I found it
The buffer_data should not be initialized when calling InternetOpenUrl.
It works for both PPC2003 and PPC2002.
However, if it is initialized, then it works only for PPC2002.
They are differences between both platform after all !!!
Patrice

"Patrice Pennetier" wrote in message
news:O%
Hello everyone,
I have an apps that works well in PPC 2002 and running it from PPC 2003 is
perfect except for the following : the handle returned from
InternetOpenUrl

is 0 in PPC 2003 and is 13356932 in PPC 2002.
It's like the internet function is not working ?
If I use XMLObjects, it works, so I know the connection is alive, but I
need

Wininet functions to read binary files.
Anybody any clues ? Am I using wrong parameters ?
Thanks

Here is the code :

'*********************
Option Explicit
Declare Function InternetOpen Lib "wininet" Alias "InternetOpenW" ( _
ByVal sAgent As String, _
ByVal lAccessType As Long, _
ByVal sProxyName As String, _
ByVal sProxyBypass As String, _
ByVal lFlags As Long) _
As Long
Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlW"
( _

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
Declare Function InternetReadFile Lib "wininet" ( _
ByVal hFile As Long, _
ByVal sBuffer As String, _
ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) _
As Integer
Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long)
As

Integer
Declare Function MultiByteToWideChar Lib "Coredll.DLL" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As String, _
ByVal cchWideChar As Long) _
As Long

Const CP_ACP = 0
Const MB_PRECOMPOSED = &H1
Const BUFFER_LEN = 256
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Const INTERNET_SERVICE_HTTP = 3
Public Function LogMe(sUrl As String) As String
Dim sBuffer As String
Dim sBuffer2 As String
Dim Buffer_Data As String
Dim hOpen As Long
Dim hFile As Long
Dim Ret As Long
Dim Len_html As Long
Dim je_sais_pas As Long
Dim Buff As Integer
Dim MyError As String
'On Error Resume Next
Buff = 2000
sBuffer = Space(Buff): Buffer_Data = Space(Buff)
hOpen = InternetOpen("test", INTERNET_OPEN_TYPE_DIRECT, vbNullString,
vbNullString, 0)
MsgBox hOpen
If hOpen <> 0 Then
hFile = InternetOpenUrl(hOpen, sUrl, Buffer_Data, Len_html,
INTERNET_FLAG_RELOAD, je_sais_pas)
MsgBox hFile 'here is where I get something in PPC2002 and 0 in PPC2003
???????
If hFile <> 0 Then
Do
InternetReadFile hFile, sBuffer, Buff, Ret
sBuffer2 = sBuffer2 & Mid(sBuffer, 1, Ret)
Loop While Ret <> 0 And Len(sBuffer2) < Buff
InternetCloseHandle hFile
End If
InternetCloseHandle hOpen
End If
MsgBox sBuffer2
MultiByteToWideChar CP_ACP, MB_PRECOMPOSED, sBuffer2, -1, Buffer_Data,
Buff

GetData = Buffer_Data
Set sBuffer = Nothing
Set sBuffer2 = Nothing
Set Buffer_Data = Nothing
Set hOpen = Nothing
Set hFile = Nothing
Set Ret = Nothing
Set Len_html = Nothing
Set je_sais_pas = Nothing
End Function




Avatar
Patrice Pennetier
Hi there,
I found it
The buffer_data should not be initialized when calling InternetOpenUrl.
It works for both PPC2003 and PPC2002.
However, if it is initialized, then it works only for PPC2002.
They are differences between both platform after all !!!
Patrice
"Patrice Pennetier" wrote in message
news:O%
Hello everyone,
I have an apps that works well in PPC 2002 and running it from PPC 2003 is
perfect except for the following : the handle returned from
InternetOpenUrl

is 0 in PPC 2003 and is 13356932 in PPC 2002.
It's like the internet function is not working ?
If I use XMLObjects, it works, so I know the connection is alive, but I
need

Wininet functions to read binary files.
Anybody any clues ? Am I using wrong parameters ?
Thanks

Here is the code :

'*********************
Option Explicit
Declare Function InternetOpen Lib "wininet" Alias "InternetOpenW" ( _
ByVal sAgent As String, _
ByVal lAccessType As Long, _
ByVal sProxyName As String, _
ByVal sProxyBypass As String, _
ByVal lFlags As Long) _
As Long
Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlW"
( _

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
Declare Function InternetReadFile Lib "wininet" ( _
ByVal hFile As Long, _
ByVal sBuffer As String, _
ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) _
As Integer
Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long)
As

Integer
Declare Function MultiByteToWideChar Lib "Coredll.DLL" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As String, _
ByVal cchWideChar As Long) _
As Long

Const CP_ACP = 0
Const MB_PRECOMPOSED = &H1
Const BUFFER_LEN = 256
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Const INTERNET_SERVICE_HTTP = 3
Public Function LogMe(sUrl As String) As String
Dim sBuffer As String
Dim sBuffer2 As String
Dim Buffer_Data As String
Dim hOpen As Long
Dim hFile As Long
Dim Ret As Long
Dim Len_html As Long
Dim je_sais_pas As Long
Dim Buff As Integer
Dim MyError As String
'On Error Resume Next
Buff = 2000
sBuffer = Space(Buff): Buffer_Data = Space(Buff)
hOpen = InternetOpen("test", INTERNET_OPEN_TYPE_DIRECT, vbNullString,
vbNullString, 0)
MsgBox hOpen
If hOpen <> 0 Then
hFile = InternetOpenUrl(hOpen, sUrl, Buffer_Data, Len_html,
INTERNET_FLAG_RELOAD, je_sais_pas)
MsgBox hFile 'here is where I get something in PPC2002 and 0 in PPC2003
???????
If hFile <> 0 Then
Do
InternetReadFile hFile, sBuffer, Buff, Ret
sBuffer2 = sBuffer2 & Mid(sBuffer, 1, Ret)
Loop While Ret <> 0 And Len(sBuffer2) < Buff
InternetCloseHandle hFile
End If
InternetCloseHandle hOpen
End If
MsgBox sBuffer2
MultiByteToWideChar CP_ACP, MB_PRECOMPOSED, sBuffer2, -1, Buffer_Data,
Buff

GetData = Buffer_Data
Set sBuffer = Nothing
Set sBuffer2 = Nothing
Set Buffer_Data = Nothing
Set hOpen = Nothing
Set hFile = Nothing
Set Ret = Nothing
Set Len_html = Nothing
Set je_sais_pas = Nothing
End Function




Avatar
Patrice Pennetier
Hi there,
I found it
The buffer_data should not be initialized when calling InternetOpenUrl.
It works for both PPC2003 and PPC2002.
However, if it is initialized, then it works only for PPC2002.
They are differences between both platform after all !!!
Patrice
"Patrice Pennetier" wrote in message
news:O%
Hello everyone,
I have an apps that works well in PPC 2002 and running it from PPC 2003 is
perfect except for the following : the handle returned from
InternetOpenUrl

is 0 in PPC 2003 and is 13356932 in PPC 2002.
It's like the internet function is not working ?
If I use XMLObjects, it works, so I know the connection is alive, but I
need

Wininet functions to read binary files.
Anybody any clues ? Am I using wrong parameters ?
Thanks

Here is the code :

'*********************
Option Explicit
Declare Function InternetOpen Lib "wininet" Alias "InternetOpenW" ( _
ByVal sAgent As String, _
ByVal lAccessType As Long, _
ByVal sProxyName As String, _
ByVal sProxyBypass As String, _
ByVal lFlags As Long) _
As Long
Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlW"
( _

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
Declare Function InternetReadFile Lib "wininet" ( _
ByVal hFile As Long, _
ByVal sBuffer As String, _
ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) _
As Integer
Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long)
As

Integer
Declare Function MultiByteToWideChar Lib "Coredll.DLL" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As String, _
ByVal cchWideChar As Long) _
As Long

Const CP_ACP = 0
Const MB_PRECOMPOSED = &H1
Const BUFFER_LEN = 256
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Const INTERNET_SERVICE_HTTP = 3
Public Function LogMe(sUrl As String) As String
Dim sBuffer As String
Dim sBuffer2 As String
Dim Buffer_Data As String
Dim hOpen As Long
Dim hFile As Long
Dim Ret As Long
Dim Len_html As Long
Dim je_sais_pas As Long
Dim Buff As Integer
Dim MyError As String
'On Error Resume Next
Buff = 2000
sBuffer = Space(Buff): Buffer_Data = Space(Buff)
hOpen = InternetOpen("test", INTERNET_OPEN_TYPE_DIRECT, vbNullString,
vbNullString, 0)
MsgBox hOpen
If hOpen <> 0 Then
hFile = InternetOpenUrl(hOpen, sUrl, Buffer_Data, Len_html,
INTERNET_FLAG_RELOAD, je_sais_pas)
MsgBox hFile 'here is where I get something in PPC2002 and 0 in PPC2003
???????
If hFile <> 0 Then
Do
InternetReadFile hFile, sBuffer, Buff, Ret
sBuffer2 = sBuffer2 & Mid(sBuffer, 1, Ret)
Loop While Ret <> 0 And Len(sBuffer2) < Buff
InternetCloseHandle hFile
End If
InternetCloseHandle hOpen
End If
MsgBox sBuffer2
MultiByteToWideChar CP_ACP, MB_PRECOMPOSED, sBuffer2, -1, Buffer_Data,
Buff

GetData = Buffer_Data
Set sBuffer = Nothing
Set sBuffer2 = Nothing
Set Buffer_Data = Nothing
Set hOpen = Nothing
Set hFile = Nothing
Set Ret = Nothing
Set Len_html = Nothing
Set je_sais_pas = Nothing
End Function




Avatar
Patrice Pennetier
Hi there,
I found it
The buffer_data should not be initialized when calling InternetOpenUrl.
It works for both PPC2003 and PPC2002.
However, if it is initialized, then it works only for PPC2002.
They are differences between both platform after all !!!
Patrice
"Patrice Pennetier" wrote in message
news:O%
Hello everyone,
I have an apps that works well in PPC 2002 and running it from PPC 2003 is
perfect except for the following : the handle returned from
InternetOpenUrl

is 0 in PPC 2003 and is 13356932 in PPC 2002.
It's like the internet function is not working ?
If I use XMLObjects, it works, so I know the connection is alive, but I
need

Wininet functions to read binary files.
Anybody any clues ? Am I using wrong parameters ?
Thanks

Here is the code :

'*********************
Option Explicit
Declare Function InternetOpen Lib "wininet" Alias "InternetOpenW" ( _
ByVal sAgent As String, _
ByVal lAccessType As Long, _
ByVal sProxyName As String, _
ByVal sProxyBypass As String, _
ByVal lFlags As Long) _
As Long
Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlW"
( _

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
Declare Function InternetReadFile Lib "wininet" ( _
ByVal hFile As Long, _
ByVal sBuffer As String, _
ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) _
As Integer
Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long)
As

Integer
Declare Function MultiByteToWideChar Lib "Coredll.DLL" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As String, _
ByVal cchWideChar As Long) _
As Long

Const CP_ACP = 0
Const MB_PRECOMPOSED = &H1
Const BUFFER_LEN = 256
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Const INTERNET_SERVICE_HTTP = 3
Public Function LogMe(sUrl As String) As String
Dim sBuffer As String
Dim sBuffer2 As String
Dim Buffer_Data As String
Dim hOpen As Long
Dim hFile As Long
Dim Ret As Long
Dim Len_html As Long
Dim je_sais_pas As Long
Dim Buff As Integer
Dim MyError As String
'On Error Resume Next
Buff = 2000
sBuffer = Space(Buff): Buffer_Data = Space(Buff)
hOpen = InternetOpen("test", INTERNET_OPEN_TYPE_DIRECT, vbNullString,
vbNullString, 0)
MsgBox hOpen
If hOpen <> 0 Then
hFile = InternetOpenUrl(hOpen, sUrl, Buffer_Data, Len_html,
INTERNET_FLAG_RELOAD, je_sais_pas)
MsgBox hFile 'here is where I get something in PPC2002 and 0 in PPC2003
???????
If hFile <> 0 Then
Do
InternetReadFile hFile, sBuffer, Buff, Ret
sBuffer2 = sBuffer2 & Mid(sBuffer, 1, Ret)
Loop While Ret <> 0 And Len(sBuffer2) < Buff
InternetCloseHandle hFile
End If
InternetCloseHandle hOpen
End If
MsgBox sBuffer2
MultiByteToWideChar CP_ACP, MB_PRECOMPOSED, sBuffer2, -1, Buffer_Data,
Buff

GetData = Buffer_Data
Set sBuffer = Nothing
Set sBuffer2 = Nothing
Set Buffer_Data = Nothing
Set hOpen = Nothing
Set hFile = Nothing
Set Ret = Nothing
Set Len_html = Nothing
Set je_sais_pas = Nothing
End Function