前のトピック: DeleteIniEntry - 初期化ファイル内のエントリの削除次のトピック: ReadIniSection - セクションの取得


DeleteIniSection - 初期化ファイルのセクションの削除

UNIX プラットフォームで有効

DeleteIniSection 関数は、指定された初期化(.ini)ファイルのエントリ セクションを削除します。

関数の形式

DeleteIniSection(section as String, filename as String) as Boolean
section

削除するセクションを指定します。

filename

初期化(.ini)ファイルの名前を指定します。

この関数が正常に完了すると、TRUE が返されます。それ以外の場合は、FALSE が返されます。

例:

以下の例では、ファイル c:\temp\test.ini、セクション LIST、およびセクション SINGLE からエントリ Entry を読み取って、出力します。 また、セクション LIST、およびセクション SINGLE のエントリ Entry を削除します。

Function strTok(in As string, BYREF pos As Integer, token As String, BYREF out As String) As Boolean
	Dim buf As String
	Dim len As Integer

	If (pos > Len(in)) Then
		strTok = FALSE
	Else
		buf = Mid(in, pos)
		len = Instr(buf, token)
		If len = 0 Then
			out = buf
			pos = pos + Len(buf) + 1
		Else
			out = Mid(buf, 0, len-1)

pos = pos + len + 1
		End If
		strTok = TRUE
	End If
End Function

Dim attrList, str, lf As string
Dim pos As Integer

' clear screen
ClrScr()

If Not(ReadIniSection("LIST", attrList, "c:\temp\test.ini")) Then
	MessageBox("Can not read LIST section", "DMS", MB_OK + MB_ICONEXCLAMATION)
	SetStatus(1)
	終了
End If
Print("[LIST]")
pos = 0
lf = chr(10)
While (strTok(attrList, pos, lf, str))
	Print(str)
Wend

If Not(ReadIniEntry("SINGLE", "Entry", attrList, "c:\temp\test.ini")) Then

MessageBox("Can not read SINGLE section", "DMS", MB_OK + MB_ICONEXCLAMATION)
	SetStatus(2)
	終了
End If

Print("[SINGLE]" + NEWLINE$ + "Entry=" + attrList)

If Not(DeleteIniEntry("SINGLE", "Entry", "c:\temp\test.ini")) Then
	MessageBox("Can not delete [SINGLE].Entry ", "DMS", MB_OK + MB_ICONEXCLAMATION)
	SetStatus(3)
	終了
End If
If Not(DeleteIniSection("LIST", "c:\temp\test.ini")) Then
	MessageBox("Can not delete LIST section", "DMS", MB_OK + MB_ICONEXCLAMATION)

SetStatus(4)
	終了
End If