能不能给的详细一点 using or Import System.Runtime.InteropServices http://archive.devx.com/dotnet/discussions/040902/cominterop.asp 好像不行也
Test.ini:[textvalues] 1=item1 2=item2 3=item3[intvalues] 1=101 2=102 3=103TestIni.cs: using System; using System.Text; using System.Runtime.InteropServices;class TestINI { [DllImport("KERNEL32.DLL")] protected internal static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName); public static void Main() { StringBuilder buffer = new StringBuilder(256); int bufLen = GetPrivateProfileString("textvalues", "1", "", buffer, buffer.Capacity, @"e:\labs\csharp\Test.ini"); Console.WriteLine(buffer.ToString()); } }by the way, you probably want to consider to use XML files instead
using or Import System.Runtime.InteropServices http://archive.devx.com/dotnet/discussions/040902/cominterop.asp
好像不行也
1=item1
2=item2
3=item3[intvalues]
1=101
2=102
3=103TestIni.cs:
using System;
using System.Text;
using System.Runtime.InteropServices;class TestINI
{ [DllImport("KERNEL32.DLL")]
protected internal static extern int GetPrivateProfileString(string lpAppName,
string lpKeyName, string lpDefault,
StringBuilder lpReturnedString, int nSize,
string lpFileName); public static void Main()
{
StringBuilder buffer = new StringBuilder(256);
int bufLen = GetPrivateProfileString("textvalues", "1", "", buffer, buffer.Capacity, @"e:\labs\csharp\Test.ini");
Console.WriteLine(buffer.ToString()); }
}by the way, you probably want to consider to use XML files instead