Answers Questions
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 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
| Print article | This entry was posted by admin on 01/25/2010 at 15:37, and is filed under Internet. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 1 month ago
please put your question in brief
about 1 month ago
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)