|
' API 関数定義
Private 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
' INIファイルから、テストデータを取得するサンプル関数
Public Sub ReadData()
Call GetIniData(
"D:\Test.ini", "TestSection", "TestKey", "")
End Sub
' 指定のINIファイルから、指定のセクション、
' キーのデータを返す関数
Public Function GetIniData(
strFileName As String, strSection As String, _
strKey As String, strDefault As String) As String
Dim strTemp As String * 256
Dim lngSize As Long
Dim strResult As String
lngSize = GetPrivateProfileString(
strSection, strKey, strDefault, _
strTemp, 256, strFileName)
strResult = LeftB(strTemp, lngSize * 2)
GetIniData = strResult
End Function
|