Question:
My Problem Is In ( Programming > Visual Basic 6.00 > API Technology > InternetReadFile Function On API )
mkbo_webmaster
2006-04-10 08:31:54 UTC
Hi, I'm an advanced prorgammer that i have a technical problem on my codes
My Problem Is In (Programming > Visual Basic 6.00 > API Technology > InternetReadFile Function On API)
I have a problem about working InternetReadFile API Function.

Problems (About InternetReadFile Function) :

1) When a URL has a technical error on its structure, my VB6 Program will not responding. And I can't control my application till the URL server timeout. And on error resume next is not effective for my problem.

2) I can't completely download the URLs with InternetReadFile , If their html length be more than 65535 and I want to change this number for my computer and how can I do this !!!!


If you answer to my question, I'll adver. your site on my URL for free.
My URL on the web is : www.mkbo.com
My Email : webmaster@mkbo.com

Thanks
Three answers:
2006-04-10 09:43:01 UTC
My first instinct is that you should upgrade as the newer versions of Microsoft development environments have much better support for this stuff.



But, barring that, I'd just have to take a few guesses.



VB 6.0 was a bit touchy about how it handled APIs. You may need to look into the variable types you're passing into the API call and its declaration - make sure you're using a current API declaration for VB 6.0 and that you have SP 6.0 installed.



InternetReadFile is designed to use a buffer to pull chunks of the response back and accumulate them. If you're trying to pull back a huge file in a single read, you may come across all kinds of limitations. It's probably better to write something more scalable like the example below. Pardon the formatting mess caused by this answers field.







Dim hInternetSession As Long

Dim hUrlFile As Long

Dim sReadBuffer As String * 4096 ' Grab 4k at a time

Dim sBuffer As String

Dim lNumberOfBytesRead As Long

Dim bDoLoop As Boolean

Dim sURL As String



hInternetSession = InternetOpen("Test", _

INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)



sURL = txtURL

hUrlFile = InternetOpenUrl(hInternetSession, _

sURL, vbNullString, 0, INTERNET_FLAG_RELOAD, 0)



bDoLoop = True

While bDoLoop

sReadBuffer = scBlankStr

bDoLoop = InternetReadFile(hUrlFile, sReadBuffer, _

Len(sReadBuffer), lNumberOfBytesRead)

sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)

If Not CBool(lNumberOfBytesRead) Then bDoLoop = False

Wend

InternetCloseHandle (hUrlFile)

InternetCloseHandle (hInternetSession)
2015-08-10 15:51:41 UTC
This Site Might Help You.



RE:

My Problem Is In ( Programming > Visual Basic 6.00 > API Technology > InternetReadFile Function On API )

Hi, I'm an advanced prorgammer that i have a technical problem on my codes

My Problem Is In (Programming > Visual Basic 6.00 > API Technology > InternetReadFile Function On API)

I have a problem about working InternetReadFile API Function.



Problems (About InternetReadFile...
2006-04-10 09:09:11 UTC
please put your question in brief


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...