PRB: GP Fault if Uninitialized String Passed to API Function (105807)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 2.0
- Microsoft Visual Basic Standard Edition for Windows 3.0
- Microsoft Visual Basic Professional Edition for Windows 2.0
- Microsoft Visual Basic Professional Edition for Windows 3.0
This article was previously published under Q105807 SYMPTOMS
When you incorrectly call a Windows API function as described in the CAUSE
section further below, you can receive a general protection (GP) fault
Application error: VB caused a General Protection Fault in VB.EXE
at nnnn:nnnn
or one of the following error messages: Assertion failed Bad handle Bad heap block CAUSE
Invoking a Windows API function in any of the following incorrect ways can
give you a GP fault or another memory violation error: - A passed string initialized to a value that is too short to receive the
return value (See example below.)
- Incorrect placement of ByVal in the Declare statement
- Undefined parameters in the function declaration or invocation
- Incorrect type or length of parameters in the function declaration or
invocation
Windows requires you to ensure memory integrity when calling API functions.
WORKAROUND
If you get a GP fault or another memory error when calling a Windows API
function, check that you have properly defined and passed all parameters.
STATUS
This behavior is by design.
REFERENCES
- "Visual Basic: Programmers Guide" for version 3.0, Chapter 24,
"Calling Procedures in DLLs."
The correct Declare statements for API functions are in the Visual Basic
Professional Edition help file WIN31API.HLP, which is located in the
WINAPI subdirectory of your Visual Basic directory. The WIN31API.HLP
file contains function declarations, Type declarations, and the values
for global constants used in the API functions.
Modification Type: | Major | Last Reviewed: | 12/9/2003 |
---|
Keywords: | kbprb KB105807 |
---|
|