Using Tabs with Initialization File APIsLast reviewed: March 12, 1996Article ID: Q132180 |
This information applies to:
SUMMARYWindows 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 INFORMATIONIf 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> ValuePart2then GetPrivateProfileString returns ValuePart1, but does not return ValuePart2 because of the tab.
Code to Demonstrate BehaviorThe 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |