C# INI파일 입,출력 소스
C#/Tip :
2009. 8. 7. 10:54
01 | using System.Runtime.InteropServices; |
02 | using Microsoft.Win32; |
03 |
04 | //ini파일 입출력 |
05 | public class IniReadWrite |
06 | { |
07 | // ---- ini 파일 의 읽고 쓰기를 위한 API 함수 선언 ---- |
08 | [DllImport( "kernel32.dll" )] |
09 | private static extern int GetPrivateProfileString( // ini Read 함수 |
10 | String section, |
11 | String key, |
12 | String def, |
13 | StringBuilder retVal, |
14 | int size, |
15 | String filePath); |
16 |
17 | [DllImport( "kernel32.dll" )] |
18 | private static extern long WritePrivateProfileString( // ini Write 함수 |
19 | String section, |
20 | String key, |
21 | String val, |
22 | String filePath); |
23 | |
24 | /// ini파일에 쓰기 |
25 | public void G_IniWriteValue(String Section, String Key, String Value, string avsPath) |
26 | { |
27 | WritePrivateProfileString(Section, Key, Value, avsPath); |
28 | } |
29 |
30 | /// ini파일에서 읽어 오기 |
31 | public String G_IniReadValue(String Section, String Key, string avsPath) |
32 | { |
33 | StringBuilder temp = new StringBuilder(2000); |
34 | int i = GetPrivateProfileString(Section, Key, "" , temp, 2000, avsPath); |
35 | return temp.ToString(); |
36 | } |
37 | } |
'C# > Tip' 카테고리의 다른 글
C# Access 데이터베이스, 테이블, 칼럼 생성 방법 (0) | 2009.08.07 |
---|---|
C# Listview 에서 칼럼헤드 클릭시 정렬 되게 하는.. (0) | 2009.08.07 |
C# 문자열 크기를 바이트크기로 (0) | 2009.08.07 |
C# listview를 선택했는지 확인 후 삭제 (0) | 2009.08.07 |
C# 문자열을 분리하기 (0) | 2009.08.07 |