//---定义
[DllImport("kernel32")]
static extern int GetPrivateProfileString(string strApplicationName,string strKeyName,string strDefalult,StringBuilder strReturnedString, long nSize,string strFileName);
//---引用
StringBuilder strCaption
strpath = @"C:\Test.ini"//该文件存在
int result = GetPrivateProfileString("DatabaseConnetion","ServerName","NULL",strCaption,strCaption.Capacity,strpath);
可是,比较怪...
StrCaption.ToString()返回的总是默认值"NULL"
[DllImport("kernel32")]
static extern int GetPrivateProfileString(string strApplicationName,string strKeyName,string strDefalult,StringBuilder strReturnedString, long nSize,string strFileName);
//---引用
StringBuilder strCaption
strpath = @"C:\Test.ini"//该文件存在
int result = GetPrivateProfileString("DatabaseConnetion","ServerName","NULL",strCaption,strCaption.Capacity,strpath);
可是,比较怪...
StrCaption.ToString()返回的总是默认值"NULL"
INI的读写API好像要求注册表中要有键值的
StringBuilder strCaptionnew StringBuilder (256);
strpath = @"C:\Test.ini
int result = GetPrivateProfileString("DatabaseConnetion","ServerName","NULL",strCaption,strCaption.Capacity,strpath);
[DatabaseConnetion]
ServerName=。
StringBuilder strCaption楼主直接用 string strcaption试试