当前位置:网站首页>c#读取INI文件和向ini文件写入数据
c#读取INI文件和向ini文件写入数据
2022-04-23 06:26:00 【大可山人】
//读取INI文件
[DllImport("kernel32")]
public static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
//向ini文件写入数据
[DllImport("kernel32")]
public static extern long WritePrivateProfileString(string mpAppName, string mpkeyName,
string mpDefault, string mpFileName);
//定时关机
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
public static extern bool ExitWindowsEx(int uFlags, int dwReserved);
//关闭,重启系统拥有所有权限
[DllImport("ntdll.dll", ExactSpelling = true, SetLastError = true)]
public static extern bool RtlAdjustPrivilege(int htok, bool disall, bool newst, ref int len);
/// <summary>
/// 从ini中读取指定的值
/// </summary>
/// <param name="section">ini的节点</param>
/// <param name="key">节点下的项目</param>
/// <param name="def">没有找到时返回默认值</param>
/// <param name="filePath">要读取的文件路径</param>
/// <returns>返回要读取的节点内容</returns>
public static string GetIniFileString(string section, string key, string def, string filePath)
{
StringBuilder temp = new StringBuilder(1024);
GetPrivateProfileString(section, key, def, temp, 1024, filePath);
return temp.ToString();
}
版权声明
本文为[大可山人]所创,转载请带上原文链接,感谢
https://blog.csdn.net/johnsuna/article/details/121639792
边栏推荐
猜你喜欢
随机推荐
Django uses MySQL database to solve error reporting
层次输出二叉树
【自我激励系列】到底是什么真正阻碍了你?
设置了body的最大宽度,但是为什么body的背景颜色还铺满整个页面?
SAP ECC连接SAP PI系统配置
js之排他思想及案例
FSM有限状态机
npm 安装踩坑
页面动态显示时间(升级版)
10. Update operation
SAP 03-AMDP CDS Table Function using ‘WITH‘ Clause(Join子查询内容)
7. sub query
NPM installation stepping pit
Solutions to common problems in visualization (VII) solutions to drawing scale setting
url转成对象
Implementation of MySQL persistence
12. Constraints
12.约束
驼峰命名对像
ABAP 实现发布RESTful服务供外部调用示例








