Read/Write INI Files w/Access 7.0 
Author Message
 Read/Write INI Files w/Access 7.0

I need to read/write INI files from Access 7.0.  I had no problem doing it
with Access 2.0 and now things won't work correctly in 7.0.  I tried
changing my declarations to use GetPrivateProfileStringA but it doesn't
work.  The WritePrivateProfileStringA works great!  Could someone please
direct me to some info on how to do this with Access 7.0?

Thanks!

John



Sat, 14 Aug 1999 03:00:00 GMT  
 Read/Write INI Files w/Access 7.0

Quote:
>I need to read/write INI files from Access 7.0.  I had no problem doing it
>with Access 2.0 and now things won't work correctly in 7.0.  I tried
>changing my declarations to use GetPrivateProfileStringA but it doesn't
>work.  The WritePrivateProfileStringA works great!  Could someone please
>direct me to some info on how to do this with Access 7.0?

Here are the Declares I use in VB4, they should be the same for Access
7 & 8:

Declare Function mtkGetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringA" ( _
    ByVal lpApplicationName As String, _
    ByVal lpKeyName As Any, _
    ByVal lpDefault As String, _
    ByVal lpReturnedString As String, _
    ByVal nSize As Long, _
    ByVal lpFileName As String) _
As Long

Declare Function mtkGetPrivateProfileSection _
Lib "kernel32" Alias "GetPrivateProfileSectionA" ( _
    ByVal lpAppName As String, _
    ByVal lpReturnedString As String, _
    ByVal nSize As Long, _
    ByVal lpFileName As String) _
As Long

Declare Function mtkGetPrivateProfileInt _
    Lib "kernel32" Alias "GetPrivateProfileIntA" ( _
    ByVal lpApplicationName As String, _
    ByVal lpKeyName As String, _
    ByVal nDefault As Long, _
    ByVal lpFileName As String) _
As Long

Declare Function mtkWritePrivateProfileSection _
Lib "kernel32" Alias "WritePrivateProfileSectionA" ( _
    ByVal lpAppName As String, _
    ByVal lpString As String, _
    ByVal lpFileName As String) _
As Long

Declare Function mtkWritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" ( _
    ByVal lpApplicationName As String, _
    ByVal lpKeyName As Any, _
    ByVal lpString As Any, _
    ByVal lpFileName As String) _
As Long

Public Function mtkWriteIni(strSection As String, strKey As String,
strEntry As String, strIni As String) As Boolean
Dim lngVal As Long
On Error GoTo WriteIni_Err

lngVal = mtkWritePrivateProfileString( _
        lpApplicationName:=strSection, _
        lpKeyName:=strKey, _
        lpString:=strEntry, _
        lpFileName:=strIni)

mtkWriteIni = True

WriteIni_Exit:
    Exit Function
WriteIni_Err:
If Err.Number <> 0 Then
    mtkWriteIni = False
 End If
 Resume WriteIni_Exit
End Function

Public Function mtkReadIni(strSection As String, strKey As String,
strIni As String) As String
Dim lngVal As Long, strBuf As String * 256

lngVal = mtkGetPrivateProfileString( _
    lpApplicationName:=strSection, _
    lpKeyName:=strKey, _
    lpDefault:="", _
    lpReturnedString:=strBuf, _
    nSize:=256, _
    lpFileName:=strIni)

If lngVal > 0 Then
    mtkReadIni = Left(strBuf, lngVal)
Else
    mtkReadIni = ""
End If

End Function

    ...Joe Maki
    MT Kupp & Associates



Sun, 15 Aug 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Reading and Writing into WIN.INI with Access V8

2. Ini-file, read write and empty lines.

3. Reading and writing from and to ini files

4. read/write an .ini file

5. Reading and writing to an INI file?

6. Reading and Writing to .ini files - help please.

7. Read and Write to INI files

8. Reading/writing to an INI file

9. Reading / Writing an INI file

10. Reading / Writing an INI file

11. How to read and write an ini file with Qbasic 4.5

12. Reading/Writing to the Registry and .INI file???

 

 
Powered by phpBB® Forum Software