Re: Trying to use *.ini file as a database record
- From: Michael B. Johnson <mjohnson@xxxxxxxxxxx>
- Date: Thu, 07 Jul 2005 10:23:21 -0500
On Thu, 7 Jul 2005 10:17:30 -0400, "RAD Software" <rad@xxxxxxxxxxxxxxx> wrote:
>I'm experimenting with using the
>
>GetPrivateProfileString and WritePrivateProfileString APIs
>
>as a way of creating and manipulating a database file.
>
>One of the first things I need to be able to do at program startup is get a
>list of the section names in the *.ini file.
>
>MS-Online says that if I call GetPrivateProfileString and use a NULL for the
>lpSectionName parameter, the function will return a Null-character delimited
>list of all the section names.
>
>So, using a 2.3mb *.ini file containing 8,181 section names, with about 10
>keynames in each section, I tried
>
>success = GetPrivateProfileString(NULL, vbnullstring, vbnullstring, sResult,
>nSize, DataFileName)
>
>but the compiler says this is an improper use of NULL.
>
>In doing a little research, I found GetPrivateProfileSectionNames, so I
>declared it and tried
>
>success = GetPrivateProfileSectionNames(sResult, nSize, DataFileName)
>
>but it returns false for success and zero for nSize.
>
>The total character space of the all the section names would be about 10,000
>characters, so I tried buffering sResult with both space(25000) and
>string(25000, Chr(0)), to no avail.
>
>Can anyone tell me what I'm doing wrong here, or have any advice as to how
>to get a list of section names in a *.ini file?
Public Sub DeleteEntry(sSectionName As String, sItemName As String)
' Purpose: To remove an entry from an INI file
' Example/Note: xxx
' !! Assumes/Pre: Nothing
' Parameters:
' sSectionName as String -
' sItemName as String -
' Returns: Nothing
' Success-
' Failure- Raises error on failure
' Revision history:
' 2005-Mar-23 12:02 [Michael Johnson] Initial creation
Dim lDummy As Long
Call TraceEnters(MODULE_NAME & "::DeleteEntry")
TraceDetail = "To remove an entry from an INI file"
'' Can't get WritePrivateProfileString to accept a Null, tried:
' Private Declare Function DeletePrivateProfileEntry Lib "kernel32" Alias
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByRef lpKeyName
As Any, lpString As Any, ByVal lpFileName As String) As Long
' lDummy = DeletePrivateProfileEntry(sSectionName, 0, 0, szFileName)
' lDummy = DeletePrivateProfileEntry(sSectionName, Null, Null, szFileName)
lDummy = WritePrivateProfileString(sSectionName, sItemName, vbNullString,
szFileName) ' << This works
ExitThis:
Call TraceExits
Exit Sub
End Sub
Having said that, you may want to do a little research into SQLite before you
settle in an INI file.
See
* http://republika.pl/roed/litex/index.html
* http://www.ch-werner.de/sqliteodbc/
The ODBC driver comes with command line tools to create an ODBC DSN connection.
(The instructions for the command line parameters is documented within the
source code, in the procedure comments.)
Hope this helps!
_______________________
Michael B. Johnson
.
- Follow-Ups:
- Re: Trying to use *.ini file as a database record
- From: RAD Software
- Re: Trying to use *.ini file as a database record
- References:
- Trying to use *.ini file as a database record
- From: RAD Software
- Trying to use *.ini file as a database record
- Prev by Date: Re: Trying to use *.ini file as a database record
- Next by Date: Re: Formatting dates and times?
- Previous by thread: Re: Trying to use *.ini file as a database record
- Next by thread: Re: Trying to use *.ini file as a database record
- Index(es):
Relevant Pages
|