Module ini


    Public ini_filename As String = Application.StartupPath() & "\DX_cw_vn.ini"

    Public ver As String
    Public get_ver As String
    Public set_wpm As Integer

    Public MyCall As String
    Public MyCall_d As String
    Public F1_m As String
    Public F1_d As String
    Public F2_m As String
    Public F2_d As String
    Public F3_m As String
    Public F3_d As String
    Public F4_m As String
    Public F4_d As String
    Public F5_m As String
    Public F5_d As String
    Public F6_m As String
    Public F6_d As String
    Public F7_m As String
    Public F7_d As String
    Public F8_m As String
    Public F8_d As String
    Public Left_m As String
    Public Down_m As String
    Public Right_m As String
    Public Left_d As String
    Public Down_d As String
    Public Right_d 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 StringAs 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 StringAs 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", ver, ini_filename)
        PutIni("My""Mycall", MyCall, ini_filename)
        PutIni("My""MyCall_d", MyCall_d, ini_filename)
        PutIni("F_key""F1_m", F1_m, ini_filename)
        PutIni("F_key""F1_d", F1_d, ini_filename)
        PutIni("F_key""F2_m", F2_m, ini_filename)
        PutIni("F_key""F2_d", F2_d, ini_filename)
        PutIni("F_key""F3_m", F3_m, ini_filename)
        PutIni("F_key""F3_d", F3_d, ini_filename)
        PutIni("F_key""F4_m", F4_m, ini_filename)
        PutIni("F_key""F4_d", F4_d, ini_filename)
        PutIni("F_key""F5_m", F5_m, ini_filename)
        PutIni("F_key""F5_d", F5_d, ini_filename)
        PutIni("F_key""F6_m", F6_m, ini_filename)
        PutIni("F_key""F6_d", F6_d, ini_filename)
        PutIni("F_key""F7_m", F7_m, ini_filename)
        PutIni("F_key""F7_d", F7_d, ini_filename)
        PutIni("F_key""F8_m", F8_m, ini_filename)
        PutIni("F_key""F8_d", F8_d, ini_filename)

        PutIni("Left_key""Left_m", Left_m, ini_filename)
        PutIni("Left_key""Left_d", Left_d, ini_filename)
        PutIni("Down_key""Down_m", Down_m, ini_filename)
        PutIni("Down_key""Down_d", Down_d, ini_filename)
        PutIni("Right_key""Right_m", Right_m, ini_filename)
        PutIni("Right_key""Right_d", Right_d, ini_filename)

        PutIni("CW""wpm", set_wpm, ini_filename)

    End Sub

    Public Sub read_ini_sub()

        get_ver = GetIni("ver""ver""", ini_filename)
        MyCall = GetIni("My""Mycall""", ini_filename)
        MyCall_d = GetIni("My""Mycall_d""", ini_filename)
        F1_m = GetIni("F_key""F1_m""", ini_filename)
        F1_d = GetIni("F_key""F1_d""", ini_filename)
        F2_m = GetIni("F_key""F2_m""", ini_filename)
        F2_d = GetIni("F_key""F2_d""", ini_filename)
        F3_m = GetIni("F_key""F3_m""", ini_filename)
        F3_d = GetIni("F_key""F3_d""", ini_filename)
        F4_m = GetIni("F_key""F4_m""", ini_filename)
        F4_d = GetIni("F_key""F4_d""", ini_filename)
        F5_m = GetIni("F_key""F5_m""", ini_filename)
        F5_d = GetIni("F_key""F5_d""", ini_filename)
        F6_m = GetIni("F_key""F6_m""", ini_filename)
        F6_d = GetIni("F_key""F6_d""", ini_filename)
        F7_m = GetIni("F_key""F7_m""", ini_filename)
        F7_d = GetIni("F_key""F7_d""", ini_filename)
        F8_m = GetIni("F_key""F8_m""", ini_filename)
        F8_d = GetIni("F_key""F8_d""", ini_filename)

        Left_m = GetIni("Left_key""Left_m""", ini_filename)
        Left_d = GetIni("Left_key""Left_d""", ini_filename)
        Down_m = GetIni("Down_key""Down_m""", ini_filename)
        Down_d = GetIni("Down_key""Down_d""", ini_filename)
        Right_m = GetIni("Right_key""Right_m""", ini_filename)
        Right_d = GetIni("Right_key""Right_d""", ini_filename)

        set_wpm = GetIni("CW""wpm""", ini_filename)

    End Sub




End Module