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

ID: Q79764


The information in this article applies to:
  • Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0
  • Microsoft Visual Basic programming system for Windows, version 1.0


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 "Too many files" (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 "kernel" (ByVal n%) 
'*** In the form: ***

Sub Form_Load ()
   n% = SetHandleCount(60)  ' Request 60 file handles.
   MsgBox "Maximum number of open files: " + Format$(n%)
End Sub 

Additional query words: 2.00 3.00

Keywords :
Version :
Platform :
Issue type :


Last Reviewed: August 19, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.