WD: Deleting an Entry Line from an .INI Settings FileLast reviewed: August 5, 1997Article ID: Q120028 |
The information in this article applies to:
SUMMARYMicrosoft WordBasic includes two statements to read and write information to a private settings file often referred to as an .INI file: SetPrivateProfileString and GetPrivateProfileString. Neither of these commands, however, allow you to remove an entire entry line from a private settings file or .INI file. The following WordBasic macro demonstrates the use of the Windows WritePrivateProfileString function in order to remove an entry from an .INI file. WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Word for Windows version 6.x
Declare Function DeleteProfileStr Lib "kernel"(Section$, Key$, \ Value As Long, FName$) As Integer Alias "WritePrivateProfileString" Sub MAIN FName$ = "C:\WINWORD\TEXT.INI" Section$ = "Section" Key$ = "Entry1" x = DeleteProfileStr(Section$, Key$, 0, FName$) End Sub Windows 95 or Windows NT
Declare Function WritePrivateProfileString Lib "kernel32" Alias \ "WritePrivateProfileStringA"(Section$, Key$, Value As Long, FName$) \ As Long Sub MAIN FName$ = "C:\TEST.INI" Section$ = "Section" Key$ = "Entry1" x = WritePrivateProfileString(Section$, Key$, 0, FName$) End Sub MORE INFORMATIONThe above WordBasic macro deletes the Entry1= line from the Text.ini file in the C:\Winword directory. Before running the macro, the contents of the Text.ini file appear as follows:
[Section] Entry1="Text for entry 1" Entry2="More text"After running the above macro the contents of the Text.ini file appear as follows:
[Section] Entry2="More text"For more information about the Windows WritePrivateProfileString function, query on the following words in the Microsoft Knowledge Base:
writeprivateprofilestring and windows and calls |
Additional query words: 6.0 6.0a WritePrivateProfileString Delete Key
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |