- 2008/12/07 [VB] INI Read / Write (3)
LazyDreamy » Search » Results » Articles
INI와 관련된 글 1개
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 LongPublic 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 FunctionPublic Function INIWrite(ByVal Session As String, ByVal KeyValue As String, ByVal DataValue As String, ByVal INIFILE As String) As String
'INI 값 기록
Dim ReturnValue As LongReturnValue = WritePrivateProfileString(Session, KeyValue, DataValue, INIFILE)
End FunctionPublic Sub SetInifile()
Dim path As String = getMyPath()
Dim filename As String = getMyFilename()'Setup.ini 세팅
INIFILE = path & "\" & filename & ".ini"
End SubPublic Function getMyPath() As String
Return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location)
End FunctionPublic 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 가 제 맛..;;
프로그램이 갈수록.. 파서 덩어리가 되가네 –_-;;;
트랙백 없음 | 댓글 3개
트랙백+댓글 | 트랙백 | 댓글
-
Comment by 드림 at 2008/12/07 11:28 / Permalink / Reply / Modify/Delete
참고 :
http://www.myhome.pe.kr/zbxe/vb/888/page/1
http://down.file.naver.com/howpc/kin.nhn?m=read§ion=read&docid=7980737&page=1315
http://www.mandki.com/bbs/board.php?bo_table=mandki&wr_id=496&sfl=&stx=&sst=wr_good&sod=desc&sop=and&page=8 -
Comment by 드림 at 2010/03/19 23:29 / Permalink / Reply / Modify/Delete
http://www.developer.com/net/asp/article.php/3287991/INI-Files-Will-Never-Die-How-To-in-NET.htm
-
Comment by 드림 at 2010/03/25 00:51 / Permalink / Reply / Modify/Delete
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
함수의 버그
str = str.Substring(0, Len(str) - 1)
str = Trim(str)
를
str = Trim(str)
str = str.Substring(0, Len(str) - 1)
순서로 해줘야 함 -
Write your comment























