-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModule1.bas
More file actions
43 lines (35 loc) · 1.6 KB
/
Module1.bas
File metadata and controls
43 lines (35 loc) · 1.6 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
Attribute VB_Name = "Module1"
Option Explicit
'API Function to read information from INI File
Public Declare Function GetPrivateProfileString 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
'API Function to write information to the INI File
Private Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any _
, ByVal lpString As Any, ByVal lpFileName As String) As Long
'Get the INI Setting from the File
Public Function GetINISetting(ByVal sHeading As String, ByVal sKey As String, sINIFileName) As String
Const cparmLen = 50
Dim sReturn As String * cparmLen
Dim sDefault As String * cparmLen
Dim lLength As Long
lLength = GetPrivateProfileString(sHeading, sKey _
, sDefault, sReturn, cparmLen, sINIFileName)
GetINISetting = Mid(sReturn, 1, lLength)
End Function
'Save INI Setting in the File
Public Function PutINISetting(ByVal sHeading As String, ByVal sKey As String, ByVal sSetting As String, sINIFileName) As Boolean
On Error GoTo HandleError
Const cparmLen = 50
Dim sReturn As String * cparmLen
Dim sDefault As String * cparmLen
Dim aLength As Long
aLength = WritePrivateProfileString(sHeading, sKey _
, sSetting, sINIFileName)
PutINISetting = True
Exit Function
HandleError:
Debug.Print Err.Number & " " & Err.Description
End Function