Internet via WINAPI: PLEASE HELP! 
Author Message
 Internet via WINAPI: PLEASE HELP!

Hi everybody!

I am working on a program that downloads different sites automatically.
I have three questions concening WINAPIs possibilities to help me do that.

1. I have the problem that my downlaod function seems to cache the contents
I am downloading. How can I avoid that using only WINAPI?

2. When I download certain sites that want to save cookies, I see the IE
popup asking wheter to save it or not. I do not want this to happen. Do you
know how to disable all cookies in WINAPI? I know how to change IE security
configuration, so please: WINAPI solutions.

3. The most serious problem I am faced with is, that some of the sites I
want to download use to time out once in a while. This situation freezes my
code. How can I tell my program to start an error handling routine after 30
seconds of inactivity?

Here is what my code looks like: (I apologize for using VB but it is the
only language I know.)

Public Sub pgFileDownloader(ByVal vUrl As String, ByVal vSavePath As String)
  Dim vInternetSession       As Long
  Dim vFile                  As Long
  Dim vPf                    As Integer
  Dim vReadBuffer()          As Byte
  Dim vNumberOfBytesRead     As Long
  Dim vDoLoop                As Boolean
  Dim vDelFile               As Boolean
  vInternetSession = InternetOpen("pgFileDownloader",
INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  vFile = InternetOpenUrl(vInternetSession, vUrl, "", 0, 0, 0)
  vPf = FreeFile
  Open vSavePath For Binary As vPf
    vDoLoop = True
    While vDoLoop
      Erase vReadBuffer()
      ReDim vReadBuffer(64)
      vDoLoop = InternetReadFile(vFile, vReadBuffer(0), 65,
vNumberOfBytesRead)
      If CBool(vNumberOfBytesRead) Then
        ReDim Preserve vReadBuffer(vNumberOfBytesRead - 1)
        Put #vPf, LOF(vPf) + 1, vReadBuffer
      Else
        vDoLoop = False
      End If
    Wend
    If LOF(vPf) = 0 Then
      vDelFile = True
    Else
      vDelFile = False
    End If
  Close #vPf
  InternetCloseHandle vFile
  InternetCloseHandle vInternetSession
  If vDelFile Then
    Kill vSavePath
  End If
End Sub

I appreciate your help,
Sebastian R.



Thu, 20 Feb 2003 14:32:30 GMT  
 Internet via WINAPI: PLEASE HELP!

Hi,

For 1 and 3 , I would suggest you just create a usercontrol and use the
AsyncRead function. To ensure updates set the option to
vbAsyncReadForceUpdate. This will also allow you to handle "freezing" as it
runs asynchronously.

As for 2, I don't know. You'd have to probably look in the registry.



Quote:
> Hi everybody!

> I am working on a program that downloads different sites automatically.
> I have three questions concening WINAPIs possibilities to help me do that.

> 1. I have the problem that my downlaod function seems to cache the
contents
> I am downloading. How can I avoid that using only WINAPI?

> 2. When I download certain sites that want to save cookies, I see the IE
> popup asking wheter to save it or not. I do not want this to happen. Do
you
> know how to disable all cookies in WINAPI? I know how to change IE
security
> configuration, so please: WINAPI solutions.

> 3. The most serious problem I am faced with is, that some of the sites I
> want to download use to time out once in a while. This situation freezes
my
> code. How can I tell my program to start an error handling routine after
30
> seconds of inactivity?

> Here is what my code looks like: (I apologize for using VB but it is the
> only language I know.)

> Public Sub pgFileDownloader(ByVal vUrl As String, ByVal vSavePath As
String)
>   Dim vInternetSession       As Long
>   Dim vFile                  As Long
>   Dim vPf                    As Integer
>   Dim vReadBuffer()          As Byte
>   Dim vNumberOfBytesRead     As Long
>   Dim vDoLoop                As Boolean
>   Dim vDelFile               As Boolean
>   vInternetSession = InternetOpen("pgFileDownloader",
> INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
>   vFile = InternetOpenUrl(vInternetSession, vUrl, "", 0, 0, 0)
>   vPf = FreeFile
>   Open vSavePath For Binary As vPf
>     vDoLoop = True
>     While vDoLoop
>       Erase vReadBuffer()
>       ReDim vReadBuffer(64)
>       vDoLoop = InternetReadFile(vFile, vReadBuffer(0), 65,
> vNumberOfBytesRead)
>       If CBool(vNumberOfBytesRead) Then
>         ReDim Preserve vReadBuffer(vNumberOfBytesRead - 1)
>         Put #vPf, LOF(vPf) + 1, vReadBuffer
>       Else
>         vDoLoop = False
>       End If
>     Wend
>     If LOF(vPf) = 0 Then
>       vDelFile = True
>     Else
>       vDelFile = False
>     End If
>   Close #vPf
>   InternetCloseHandle vFile
>   InternetCloseHandle vInternetSession
>   If vDelFile Then
>     Kill vSavePath
>   End If
> End Sub

> I appreciate your help,
> Sebastian R.



Thu, 20 Feb 2003 14:56:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Internet via WINAPI: PLEASE HELP!

2. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

3. VB6, WINAPI and .INI files - Please help if you can

4. << -- WinAPI : FINDREPLACE - please help

5. WinAPI help, please!

6. << -- WinAPI : FINDREPLACE - please help

7. << -- WinAPI : FINDREPLACE - please help

8. Please help with WinAPI

9. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

10. Connecting to Access via Visual Basic via Internet

11. Updating PC Date/Time via WinAPI

12. Rubberband Rectangle in ACCESS-Form via WinApi

 

 
Powered by phpBB® Forum Software