출처: http://terrorjang.tistory.com/21
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices; //class 추가
namespace Login
{
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
}
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal,
int size, string filePath);
private void btnLogin_Click(object sender, EventArgs e)
{
//..ini 쓰기
WritePrivateProfileString("LOGIN", "ID", "test", "C:\\login.ini");
WritePrivateProfileString("LOGIN", "PW", "1234", "C:\\login.ini");
StringBuilder retId = new StringBuilder();
StringBuilder retPw = new StringBuilder();
//..ini 읽기
GetPrivateProfileString("LOGIN", "ID", "(NONE)", retId, 32, "C:\\login.ini");
GetPrivateProfileString("LOGIN", "PW", "(NONE)", retPw, 32, "C:\\login.ini");
MessageBox.Show("ID :"+ retId.ToString()+",PW: "+ retPw.ToString());
}
}
}
'언어 > C#' 카테고리의 다른 글
비활성창 매크로 만들기 (0) | 2018.03.09 |
---|---|
ZylSerialPort.NET define (0) | 2018.02.19 |
directory관련 (0) | 2018.02.19 |
winform 설치(setup) 프로그램 만들기 (0) | 2018.02.19 |
C# 웹서비스로 JSON 결과값 생성하기 (0) | 2018.02.18 |