Microsoft KB Archive/199856

= FIX: SIZE Command Does Not Work in Internet Transfer Control =

Article ID: 199856

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q199856



SYMPTOMS
When you use the Internet Transfer Control to run the SIZE command, icResponseCompleted is not returned to the StateChanged event, and you cannot obtain a size.



CAUSE
This problem occurs because the Internet Transfer Control is not properly handling the WM_INET_FTPSIZE message.



RESOLUTION
To obtain a file size through a Visual Basic application, you can use the FtpFindFirstFile and InternetFindNextFile WinInet functions directly.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Internet Transfer Control that shipped with Microsoft Visual Basic 6.0.



MORE INFORMATION
The following code illustrates the problem: Private Sub Command1_Click Inet1.Execute "ftp://server", "size /" End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer) Dim vtData As Variant ' Data variable. Select Case State ' ... Other cases are not shown.

Case icResponseCompleted ' 12 vtData = Inet1.GetChunk(1024) End Select

Text1.Text = vtData End Sub An example of the code that is necessary to implement the workaround is available in the VBFTP.exe sample, which is available from the following Microsoft Knowledge Base article:

175179 SAMPLE: VBFTP.EXE: Implementing FTP Using WinInet API from VB

This sample uses the FtpFindFirstFile and InternetFindNextFile functions to populate a tree view of the files that are available on the FTP server. A WIN32_FIND_DATA structure is passed to these functions that, after the function is run, will contain the size of the found file. The WIN32_FIND_DATA structure contains the nFileSizeHigh and nFileSizeLow members, which represent the size of the file. The Win32 Software Development Kit (SDK) describes these members as follows:

nFileSizeHigh

Specifies the high-order DWORD value of the file size, in bytes. This value is zero unless the file size is greater than MAXDWORD. The size of the file is equal to (nFileSizeHigh * MAXDWORD) + nFileSizeLow.

nFileSizeLow

Specifies the low-order DWORD value of the file size, in bytes.

MAXDWORD is defined in WinNT.h as follows: This can be defined in Visual Basic as follows: Public Const MAXDWORD = &Hffffffff IMPORTANT: WinInet uses a LIST command to gather information about the files on an FTP server. Some FTP servers do not return data in a format that WinInet can parse. In this case, the above work around will not work.
 * 1) define MAXDWORD   0xffffffff

Additional query words: broken

Keywords: kbbug kbfix KB199856

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.