Microsoft KB Archive/132180

{|
 * width="100%"|

Using Tabs with Initialization File APIs

 * }

Q132180

-

The information in this article 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 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 query words: 95 4.00

Keywords : kbenv

Issue type :

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch kbWin32SDK400