Module ini
Public ini_filename As String = Application.StartupPath() & "\read_Hamlog.ini"
Public var As String
Public get_var As String
Public calls As String
Public qth As String
Public Position_left As String
Public Position_top As String
Public Position_right As String
Public Position_bottom As String
Declare Function WritePrivateProfileString _
Lib "KERNEL32.DLL" Alias "WritePrivateProfileStringA" ( _
ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpString As String, _
ByVal lpFileName As String) As Integer
Declare Function GetPrivateProfileString _
Lib "KERNEL32.DLL" Alias "GetPrivateProfileStringA" ( _
ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Integer, _
ByVal lpFileName As String) As Integer
Public Function GetIni(ByVal ApName As String, _
ByVal KeyName As String, _
ByVal Defaults As String, _
ByVal Filename As String _
) As String
'INIファイルから参照したいキーの値を取得する
'ApName : セクション名
'KeyName : 項目名
'Default : 項目が存在しない場合の初期値
'FileName : 参照ファイル名
'****************************************
Dim strResult As String = Space(255)
Call GetPrivateProfileString(ApName, KeyName, Defaults, _
strResult, Len(strResult), _
Filename)
GetIni = Microsoft.VisualBasic.Left(strResult, _
InStr(strResult, Chr(0)) - 1)
End Function
Public Sub PutIni(ByVal ApName As String, _
ByVal KeyName As String, _
ByVal Param As String, _
ByVal Filename As String)
'INIファイルに新たなキーの値を書込む
' ※既存のキーがあれば更新・なければ新規作成する
'ApName : セクション名
'KeyName : 項目名
'Param : 更新する値
'FileName : 書出ファイル名
'****************************************
Call WritePrivateProfileString(ApName, KeyName, _
Param, Filename)
End Sub
Public Sub write_ini_sub()
PutIni("ver", "ver", "0.01", ini_filename)
PutIni("THW", "calls", calls, ini_filename)
PutIni("THW", "qth", qth, ini_filename)
End Sub
Public Sub read_ini_sub()
get_var = GetIni("ver", "ver", "", ini_filename)
calls = GetIni("THW", "calls", "", ini_filename)
qth = GetIni("THW", "qth", "", ini_filename)
End Sub
End Module