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

ID Number: Q79764

1.00

WINDOWS

Summary:

Visual Basic programs normally may not have more than 15 files open at

once. Visual Basic 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.

This information applies to Microsoft Visual Basic programming system

version 1.0 for Windows.

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 reference words: 1.00