Microsoft KB Archive/79764

= Use SetHandleCount to Open More than 15 Files at Once in VB =

Article ID: 79764

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition
 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q79764



SUMMARY
Microsoft Visual Basic for Windows programs normally may not have more than 15 files open at once. Visual Basic for Windows displays the error message &quot;Too many files&quot; (error code 67) when you attempt to open more than the maximum number of files at once. You can increase the maximum number of open files by calling the Windows API function SetHandleCount.



MORE INFORMATION
The Windows API function SetHandleCount requests Windows to change the maximum number of files a program can open. SetHandleCount returns the actual number of handles that the program can use, which may be less than the number requested.

The FILES= statement in the CONFIG.SYS file does not limit the number of files available to a Microsoft Windows program.

Do not attempt to increase the number of files with MS-DOS interrupt 21 hex with function 67 hex. This interrupt does not record information needed by Windows.

Example
The following code example demonstrates how to use SetHandleCount:

'*** In the global module: *** Declare Function SetHandleCount% Lib &quot;kernel&quot; (ByVal n%) '*** In the form: *** Sub Form_Load n% = SetHandleCount(60) ' Request 60 file handles. MsgBox &quot;Maximum number of open files: &quot; + Format$(n%) End Sub

Additional query words: 2.00 3.00

Keywords: KB79764

-

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

© Microsoft Corporation. All rights reserved.