'(NOTE: Profile calls *altered* from those found in WIN30API.TXT!)
Declare Function kpGetProfileInt Lib "Kernel" Alias "GetProfileInt" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Integer) As Integer
Declare Function kpGetProfileString Lib "Kernel" Alias "GetProfileString" (ByVal lpAppName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer) As Integer
Declare Function kpWriteProfileString Lib "Kernel" Alias "WriteProfileString" (ByVal lpAppName As Any, ByVal lpKeyName As Any, ByVal lpString As Any) As Integer
Declare Function kpGetPrivateProfileInt Lib "Kernel" Alias "GetPrivateProfileInt" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
Declare Function kpGetPrivateProfileString Lib "Kernel" Alias "GetPrivateProfileString" (ByVal lpAppName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Declare Function kpWritePrivateProfileString Lib "Kernel" Alias "WritePrivateProfileString" (ByVal lpAppName As Any, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Integer
Declare Function kpSendMessage Lib "User" Alias "SendMessage" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
Declare Function kpGetWindowsDirectory Lib "Kernel" Alias "GetWindowsDirectory" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
'** Module-level variables for [Section] and Ini file names
Dim smSectionName As String 'Current section in private Ini file
Dim smIniFileName As String 'Fully qualified path/name of current private Ini file
Dim smWinSection As String 'Current section in Win.Ini
Dim nmWinInit As Integer 'Flag to indicate that Win.Ini section is initialized
Dim nmPrivInit As Integer 'Flag to indicate that Private.Ini is initialized
Dim nmSysPath As Integer 'Flag to indicate whether paths should be used with DEVICE=
'** Constants used to size buffers
Const Max_SectionBuffer = 8192
Const Max_EntryBuffer = 255
'** Special values to alert other apps of Win.Ini changes
Const HWND_BROADCAST = &HFFFF
Const WM_WININICHANGE = &H1A
Function ExtractName$ (sSpecIn$, nBaseOnly%)
Dim nCnt%, nDot%, sSpecOut$
On Local Error Resume Next
If InStr(sSpecIn, "\") Then
For nCnt = Len(sSpecIn) To 1 Step -1
If Mid$(sSpecIn, nCnt, 1) = "\" Then
sSpecOut = Mid$(sSpecIn, nCnt + 1)
Exit For
End If
Next nCnt
ElseIf InStr(sSpecIn, ":") = 2 Then
sSpecOut = Mid$(sSpecIn, 3)
Else
sSpecOut = sSpecIn
End If
If nBaseOnly Then
nDot = InStr(sSpecOut, ".")
If nDot Then
sSpecOut = Left$(sSpecOut, nDot - 1)
End If
End If
ExtractName$ = UCase$(sSpecOut)
End Function
Function ExtractPath$ (sSpecIn$)
Dim nCnt%, sSpecOut$
On Local Error Resume Next
If InStr(sSpecIn, "\") Then
For nCnt = Len(sSpecIn) To 1 Step -1
If Mid$(sSpecIn, nCnt, 1) = "\" Then
sSpecOut = Left$(sSpecIn, nCnt)
Exit For
End If
Next nCnt
ElseIf InStr(sSpecIn, ":") = 2 Then
sSpecOut = CurDir$(sSpecIn)
If Len(sSpecOut) = 0 Then sSpecOut = CurDir$
Else
sSpecOut = CurDir$
End If
If Right$(sSpecOut, 1) <> "\" Then
sSpecOut = sSpecOut + "\"
End If
ExtractPath$ = UCase$(sSpecOut)
End Function
Sub Main ()
'This subroutine is useful for simply testing the other routines in this
'module. Make this module the only one in a project, and set Sub Main as
'the entry point. Then enter the code you wish to test below.
End Sub
Sub PrivClearEntry (sEntryName As String)
'Bail if not initialized
If Not nmPrivInit Then
PrivIniNotReg
Exit Sub
End If
'Sets a specific entry in Private.Ini to Nothing or Blank