Using Tabs with Initialization File APIs

Last reviewed: March 12, 1996
Article ID: Q132180
This information applies to:
  • Microsoft Win32 Software Development Kit (SDK) version 4.0

SUMMARY

Windows 95 does not support the use of the tab (that is, \t) character as part of the lpszString parameter of WritePrivateProfileString or WriteProfileString. In addition, GetPrivateProfileString does not return any characters in a key that occur after a tab character.

This behavior is for backward compatibility with applications that assume that comments are separated from entries by tabs.

NOTE: Windows NT does support the use of the tab character.

MORE INFORMATION

If a call made to either WritePrivateProfileString or WriteProfileString that contains the tab character as part of the lpszString parameter, the desired effect will not occur. Both of these functions will return TRUE (that is, successful completion); however, any data that was to follow the tab character will be missing. The newly created or modified key of the .INI file will indicate the loss of data.

When using the GetPrivateProfileString API to retrieve a string from a specified section in an .INI file, if the string is in the form:

   lpszKey=ValuePart1 <tab> ValuePart2

then GetPrivateProfileString returns ValuePart1, but does not return ValuePart2 because of the tab.

Code to Demonstrate Behavior

The following code demonstrates this loss of data after a call to WritePrivateProfileString:

void main()
{
     char szBuf[200];

     if ( !WritePrivateProfileString("TEST",
           "TESTKEY",
           "Test String \t more text",
           "TEST.INI")  )
     {
           FormatMessage(
                FORMAT_MESSAGE_FROM_SYSTEM,
                NULL,
                GetLastError(),
                MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
                szBuf,
                199,
                NULL );

           MessageBox(NULL, szBuf,
                 "Error calling WritePrivateProfileString",
                 MB_OK);
     }
}


Additional reference words: 95 4.00
KBCategory: kbenv
KBSubcategory: KrMisc


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: March 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.