LazyDreamy

관리자 | 글쓰기

LazyDreamy » Search » Results » Articles

INI와 관련된 글 1개

  1. 2008/12/07 [VB] INI Read / Write (3)

LazyDreamy » Computer/Programming

[VB] INI Read / Write

드림 | 2008/12/07 11:13

Public INIFILE As String

'INI 스트링을 읽어오기 위한 API 선언
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
    (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, _
    ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Long

'INI 스트링을 기록하기 위한 API 선언
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

Public Function INIRead(ByVal Session As String, ByVal KeyValue As String, ByVal INIFILE As String) As String
    'INI 값 읽기
    Dim str As String
    Dim ReturnValue As Long
    str = Space(255)

    ReturnValue = GetPrivateProfileString(Session, KeyValue, "", str, 255, INIFILE)
    str = str.Substring(0, Len(str) - 1)
    str = Trim(str)
    INIRead = str
End Function

Public Function INIWrite(ByVal Session As String, ByVal KeyValue As String, ByVal DataValue As String, ByVal INIFILE As String) As String
    'INI 값 기록
    Dim ReturnValue As Long

    ReturnValue = WritePrivateProfileString(Session, KeyValue, DataValue, INIFILE)
End Function

Public Sub SetInifile()
    Dim path As String = getMyPath()
    Dim filename As String = getMyFilename()

    'Setup.ini 세팅
    INIFILE = path & "\" & filename & ".ini"
End Sub

Public Function getMyPath() As String
    Return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location)
End Function

Public Function getMyFilename() As String
    Return System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly.Location)
End Function


사용


INIWrite("session", "key", "value", INIFILE)
INIRead("session", "key", INIFILE))


설정파일엔 ini 가 제 맛..;;
프로그램이 갈수록.. 파서 덩어리가 되가네 –_-;;;

2008/12/07 11:13 2008/12/07 11:13


태그 , ,

(go to top)