DOCERR: GetPrivateProfileString Declaration Incorrect in API

Last reviewed: October 25, 1995
Article ID: Q110826
The information in this article applies to:
  • Professional Edition of Microsoft Visual Basic for Windows, version 3.0
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic for Windows, version 4.0

SUMMARY

This article corrects a documentation error for the GetPrivateProfileString function call as described in the Windows version 3.1 API Reference help file that shipped with Microsoft Visual Basic version 3.0 for Windows.

This same documentation error occurs in Visual Basic version 4.0 in the WIN32API.TXT file.

MORE INFORMATION

The declaration is incorrectly shown as:

Declare Function GetPrivateProfileString Lib "Kernel"
                                 (ByVal lpApplicationName As String,
                                  lpKeyName As Any,
                                  ByVal lpDefault As String,
                                  ByVal lpReturnedString As String,
                                  ByVal nSize As Integer,
                                  ByVal lpFileName As String) As Integer

The correct declaration is as follows:

Declare Function GetPrivateProfileString Lib "Kernel"
                                 (ByVal lpApplicationName As String,
                                  ByVal lpKeyName As Any,
                                  ByVal lpDefault As String,
                                  ByVal lpReturnedString As String,
                                  ByVal nSize As Integer,
                                  ByVal lpFileName As String) As Integer

NOTE: Each Declare statement must be entered as one, single line.

Notice that the "ByVal" keyword was omitted from the second parameter in the online reference. This means that the function is passing the second parameter (lpKeyName) by reference. It needs to be passed by value.

The most common problem that occurs when using the incorrect declaration is that when the function is called, it returns a copy of "lpdefault" in the "lpReturnedString" parameter instead of the actual value referenced by KeyName.


Additional reference words: 3.00 4.00
KBCategory: kbref kbdocerr
KBSubcategory: RefsDoc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 25, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.