Public 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 Public 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 '---------- iniファイルから数値を取得する ---------- Public Function WIN32API_Get_INI_nValue(SubName As String, Default As Long) As Long Dim Meinname As String Dim nFileName As String Dim Ret As Long Meinname = App.Title nFileName = App.Path & "\" & App.Title & ".ini" Ret = GetPrivateProfileInt(Meinname, SubName, Default, nFileName) WIN32API_Get_INI_nValue = Ret End Function '---------- iniファイルに文字列を書き込む ---------- Public Sub WIN32API_Put_INI_Value(SubName As String, WriteName As String) Dim Meinname As String Dim nFileName As String Dim Ret As Long ' Meinname = App.Title nFileName = App.Path & "\" & App.Title & ".ini" ' Ret = WritePrivateProfileString(Meinname, SubName, WriteName, nFileName) End Sub '---------- アクティブなオプションボタンの配列番号 ---------- Public Function VBC_AskTrueOptBtn(OptBtn As Object) As Integer Dim i As Integer Dim bFlag As Boolean bFlag = False ' For i = 0 To OptBtn.Count - 1 If OptBtn(i).Value = True Then bFlag = True Exit For End If Next i If bFlag = False Then VBC_OccurError ("アクティブなオプションボタンが無い") End If VBC_AskTrueOptBtn = i End Function '---------- iniファイルの読込 ---------- Public Sub IniFileRead() '########## MDT処理 ########## '再起動変換のチェックボタンを読込 frmmain.ChkReboot.Value = WIN32API_Get_INI_nValue("RebootOption", 0) '########## 変換タイプのオプションボタンを読込 ########## Dim nTranstype As Integer nTranstype = WIN32API_Get_INI_nValue("TransType", 0) frmmain.OptTranstype(nTranstype).Value = True '########## フォームの高さと幅を読込 ########## If WIN32API_Get_INI_nValue("WindowState", 0) = 2 Then frmmain.WindowState = 2 Else frmmain.Height = WIN32API_Get_INI_nValue("FormHeight", 5955) frmmain.Width = WIN32API_Get_INI_nValue("FormWidth", 7350) End If End Sub '---------- iniファイルの書出 ---------- Public Sub IniFileWrite() '########## MDT処理 ########## '再起動変換のオプションボタンを保存 Call WIN32API_Put_INI_Value _ ("RebootOption", CStr(frmmain.ChkReboot.Value)) '########## 変換タイプのオプションボタンを保存 ########## Dim nTranstype As Integer nTranstype = VBC_AskTrueOptBtn(frmmain.OptTranstype) Call WIN32API_Put_INI_Value("TransType", CStr(nTranstype)) '########## フォームの高さと幅を保存 ########## ' Debug.Print frmmain.Height ' Debug.Print frmmain.Width ' Debug.Print frmmain.WindowState If frmmain.WindowState = 0 Then Call WIN32API_Put_INI_Value("FormHeight", CStr(frmmain.Height)) Call WIN32API_Put_INI_Value("FormWidth", CStr(frmmain.Width)) Call WIN32API_Put_INI_Value("WindowState", "0") ElseIf frmmain.WindowState = 1 Then ElseIf frmmain.WindowState = 2 Then Call WIN32API_Put_INI_Value("WindowState", "2") End If End Sub