Bqyahoo bug 3

xiaoxiao2021-03-06  223

Finally, how to use white functions Internetopenurl and InternetReadFile.

Yesterday, tested Bqyahoo with a friend on an online friend. InternetReadFile can only read the first half of the web page, and the second half is not, which will not be possible. I think of course: His speed is too slow, can't keep up with the rhythm of the program. At that time, he reminded me: His network speed is not slow.

Later I knew myself.

After get off work, I secretly use the department's server for testing. At present, both employee machines must use the agent to access the external network, for restrictions on the Internet. This server can directly access the external network, and the speed is very fast, in fact, this server is used to access the foreign network, but the number of visits is small.

This server visits Yahoo! The speed is very fast, can reach 200K per second. That is at this speed, InternetReadFile still only reads the first half of the web page. I met at the time, this happened, not the network speed is too slow, but it is too fast.

A close look msdn, get below this passage: InternetReadFile operates much like the base ReadFile function, with a few exceptions Typically, InternetReadFile retrieves data from an HINTERNET handle as a sequential stream of bytes The amount of data to be read for each call.. to InternetReadFile is specified by the dwNumberOfBytesToRead parameter and the data is returned in the lpBuffer parameter. A normal read retrieves the specified dwNumberOfBytesToRead for each call to InternetReadFile until the end of the file is reached. to ensure all data is retrieved, an application must continue to call the InternetReadFile function until the function returns TRUE and the lpdwNumberOfBytesRead parameter equals zero. This is especially important if the requested data is written to the cache, because otherwise the cache will not be properly updated and the file downloaded will not be committed to the Cache. Note That Caching Happens Automatic Unless The Original Request To Open The Data Street Set The Internet_Flag_no _Cache_Write Flag.

When an application retrieves a handle using InternetOpenUrl, WinINet attempts to make all data look like a file download, in an effort to make reading from the Internet easier for the application. For some types of information, such as FTP file directory listings and Gopher directory listings, it converts the data to be returned by InternetReadFile to an HTML stream. It does this on a line-by-line basis. For example, it can convert an FTP directory listing to a line of HTML and return this HTML to the application .WinINet attempts to write the HTML to the lpBuffer buffer a line at a time. If the application's buffer is too small to fit at least one line of generated HTML, the error code ERROR_INSUFFICIENT_BUFFER is returned as an indication to the application that it needs a larger buffer. Also, converted lines might not completely fill the buffer, so InternetReadFile can return with less data in lpBuffer than requested. Subsequent reads will retrieve all the converted HTML. The applic Ation Must Again Check That All Data is Retrieved As Described Previously.

Under the guidance of this paragraph, I finally used the Internetopenurl and InternetReadFile.

Only the history of reading half a page is finally not returned!

At 8 o'clock in the evening, I was successfully tested on the machine to directly access the external network.

转载请注明原文地址:https://www.9cbs.com/read-128799.html

New Post(0)