-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodINI.bas
More file actions
41 lines (32 loc) · 1.96 KB
/
Copy pathmodINI.bas
File metadata and controls
41 lines (32 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Attribute VB_Name = "modINI"
Option Explicit
#If Win16 Then
Declare Function WritePrivateProfileString Lib "Kernel" (ByVal AppName As String, ByVal KeyName As String, ByVal NewString As String, ByVal filename As String) As Integer
Declare Function GetPrivateProfileString Lib "Kernel" Alias "GetPrivateProfilestring" (ByVal AppName As String, ByVal KeyName As Any, ByVal default As String, ByVal ReturnedString As String, ByVal MAXSIZE As Integer, ByVal filename As String) As Integer
#Else
' NOTE: The lpKeyName argument for GetPr
' ofileString, WriteProfileString,
'GetPrivateProfileString, and WritePriva
' teProfileString can be either
'a string or NULL. This is why the argum
' ent is defined as "As Any".
' For example, to pass a string specifyB
' yVal "wallpaper"
' To pass NULL specifyByVal 0&
'You can also pass NULL for the lpString
' argument for WriteProfileString
'and WritePrivateProfileString
' Below it has been changed to a string
' due to the ability to use vbNullString
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
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As Any, ByVal lpFileName As String) As Long
#End If
Function ReadINI(Section, KeyName, filename As String) As String
Dim sRet As String
sRet = String(255, Chr(0))
ReadINI = Left(sRet, GetPrivateProfileString(Section, ByVal KeyName, "", sRet, Len(sRet), filename))
End Function
Function writeini(sSection As String, sKeyName As String, sNewString As String, sFileName) As Integer
Dim r
r = WritePrivateProfileString(sSection, sKeyName, sNewString, sFileName)
End Function