Part IV: Professional Database Development
966
Dim lenPath As Integer
Dim IniPath As String
IniPath = CurrentProject.Path & “\”
Filename = IniPath & “TEST.INI”
Section = “Settings”
Setting = GetTitleSetting()
Select Case Setting
Case 1
KeyName = “AppTitle”
Value = “Microsoft Access - “ & GetUserName()
RetVal = apiWritePrivateProfileString( _
Section, KeyName, Value, FileName)
Value = “2”
KeyName = “TitleBar”
RetVal = apiWritePrivateProfileString( _
Section, KeyName, Value, FileName)
Case 2
KeyName = “AppTitle”
Value = “My Access Application”
RetVal = apiWritePrivateProfileString( _
Section, KeyName, Value, FileName)
KeyName = “TitleBar”
Value = “1”
RetVal = apiWritePrivateProfileString( _
Section, KeyName, Value, FileName)
Case Else
End Select
End Sub
WriteProfileStringA
WriteProfileStringA behaves much like WritePrivateProfileStringA, except it
doesn’t accept a filename as a parameter:
Declare Function apiWriteProfileString _
Lib “Kernel32” _
Alias “WriteProfileStringA”( _
ByVal lpszSection As String, _
ByVal lpszKey As String, _
ByVal lpszSetting As String) As Long
Like GetProfileStringA, this function only works on the win.ini file. If the function com-
pletes successfully, a nonzero value is returned; if not, zero is returned.