Created
February 10, 2014 09:30
-
-
Save 284km/8912899 to your computer and use it in GitHub Desktop.
c# での ini ファイル読み込み
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
public class xxxController | |
{ | |
private const string XXX = "xxx"; | |
[DllImport("KERNEL32.DLL")] | |
public static extern uint | |
GetPrivateProfileString(string lpAppName, | |
string lpKeyName, string lpDefault, | |
StringBuilder lpReturnedString, uint nSize, | |
string lpFileName); | |
public void xxx() | |
{ | |
string iniFileName = AppDomain.CurrentDomain.BaseDirectory + "xxx\\yyy.ini"; | |
// iniファイルから文字列を取得 | |
StringBuilder sb = new StringBuilder(1024); | |
GetPrivateProfileString( | |
"category", // セクション名 | |
"category", // キー名 | |
"", // 値が取得できなかった場合に返される初期値 | |
sb, // 格納先 | |
Convert.ToUInt32(sb.Capacity), // 格納先のキャパ | |
iniFileName); // iniファイル名 | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment