home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 8460
- ClientLeft = 1140
- ClientTop = 1515
- ClientWidth = 6690
- Height = 8865
- Left = 1080
- LinkTopic = "Form1"
- ScaleHeight = 8460
- ScaleWidth = 6690
- Top = 1170
- Width = 6810
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Declare Function GetProfileInt Lib "kernel32" _
- Alias "GetProfileIntA" (ByVal lpAppName As String, _
- ByVal lpKeyName As String, ByVal nDefault As Long) As Long
- Private Declare Function GetProfileString Lib "kernel32" _
- Alias "GetProfileStringA" (ByVal lpAppName As String, _
- ByVal lpKeyName As String, ByVal lpDefault As String, _
- ByVal lpReturnedString As String, ByVal nSize As Long) As Long
- Private Declare Function WriteProfileString Lib "kernel32" _
- Alias "WriteProfileStringA" (ByVal lpszSection As String, _
- ByVal lpszKeyName As String, ByVal lpszString As String) As Long
- Private Declare Function GetPrivateProfileInt Lib "kernel32" _
- Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, _
- ByVal lpKeyName As String, ByVal nDefault As Long, _
- ByVal lpFileName As String) As Long
- Private Declare Function GetPrivateProfileString Lib "kernel32" _
- Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
- ByVal lpKeyName As String, ByVal lpDefault As String, _
- ByVal lpReturnedString As String, ByVal nSize As Long, _
- ByVal lpFileName As String) As Long
- Private Declare Function WritePrivateProfileString Lib "kernel32" _
- Alias "WritePrivateProfileStringA" _
- (ByVal lpApplicationName As String, ByVal lpKeyName As String, _
- ByVal lpString As String, ByVal lpFileName As String) As Long
- Dim secName As String
- Dim keyName As String
- Dim prvName As String
- Private Sub Form_Load()
- Dim keyValue As String
- secName = "VB Unleashed"
- keyName = "Chapter Number"
- prvName = "sams.ini"
- keyValue = "22-Using the Windows 95 APIs"
- testPrivateProfile
- WritePrivateProfileString secName, keyName, keyValue, prvName
- testPrivateProfile
- WritePrivateProfileString secName, keyName, "", prvName
- testPrivateProfile
- End Sub
- Private Sub testProfile()
- Dim lChapNum As Long
- Dim sChapNum As String
- lChapNum = GetProfileInt(secName, keyName, 10)
- sChapNum = Space(50)
- GetProfileString secName, keyName, "10", sChapNum, Len(sChapNum)
- MsgBox "Chapter Int = " & lChapNum
- MsgBox "Chapter Str = " & sChapNum
- End Sub
- Private Sub testPrivateProfile()
- Dim lChapNum As Long
- Dim sChapNum As String
- lChapNum = GetPrivateProfileInt(secName, keyName, 10, prvName)
- sChapNum = Space(50)
- GetPrivateProfileString secName, keyName, "10", sChapNum, Len(sChapNum), prvName
- MsgBox "Private Chapter Int = " & lChapNum
- MsgBox "Private Chapter Str = " & sChapNum
- End Sub
-