iniファイルより値を取得する
'
'iniファイルより値を取得する
'
'引数:strObjPath iniファイル名(フルパス)
' :strSectionName - セクション名
' :strKey - キー名称
' :strDefstr - デフォルト文字列
'
' 戻値 : String - 取得した文字列
' エラー時はNULL
'
Public Function getValueFromIniFile(strObjPath
As String, strSectionName As String, strKey
As String, Optional strDefstr As String=vbNullstring)
As String
Dim strBuf As String * 255 '文字列取得バッファ
Dim strResult As String '文字列取得結果
Dim lngRet As Long 'API戻り値
On Error GoTo ErrorHandler
getValueFromIniFile = ""
lngRet = GetPrivateProfileString(strSectionName,
strKey, strDefstr, strBuf, Len(strBuf), strObjPath)
'不要文字列切り取り
strResult = Trim(strBuf)
strResult = Mid$(strResult, 1, Len(strResult)
- 1)
getValueFromIniFile = strResult
Exit Function
ErrorHandler:
End Function