Using Quoted Strings with Profile String Functions

Last reviewed: November 2, 1995
Article ID: Q69752
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.0 and 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

Microsoft Windows provides profile files which are a mechanism for an application to store configuration about itself. The WIN.INI file is the system profile file in which Windows stores configuration information about itself. In versions of Windows prior to version 3.0, applications also stored configuration information in the WIN.INI file. Windows 3.0 introduced private profile files, which can store application-specific information.

An application can retrieve information from a profile file by calling the GetProfileString or GetPrivateProfileString function. If the profile file associates the specified lpKeyName value with a string that is delimited by quotation marks, Windows discards the quotation marks when it copies the associated string into the application- provided buffer.

For example, if the following entry appears in the profile file:

   [application name]           [application name]
   keyname = 'string'     or     keyname = "string"

The GetPrivateProfileString and GetProfileString functions read the string value and discard the quotation marks.

MORE INFORMATION

This behavior allows spaces to be put into a string. For example, the profile entry

   keyname = string

returns the string without a leading space, whereas

   keyname = ' string'     or     keyname = " string"

returns the string with a leading space.

Doubling quotation marks includes quotation marks in the string. For example:

   keyname = ''string''    or     keyname = ""string""

returns the string with its quotation marks -- 'string' or "string".


Additional reference words: 3.00 3.10 3.50 3.51 4.00 95
KBCategory: kbui
KBSubcategory: UsrIni


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: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.