当前位置:网站首页>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
边栏推荐
- Authorization server (simple construction of authorization server)
- MySQL index
- SAP pi / PO rfc2soap publishes RFC interface as WS example
- Nacos / sentinel gateway current limiting and grouping (code)
- 反思 | Android 音视频缓存机制的系统性设计
- 6.聚合函数和分组统计
- BTREE, B + tree and hash index
- The difference and application of VR, AR and MR, as well as some implementation principles of AR technology
- 移动布局(flex布局、视口标签)
- ABAP CDS VIEW WITH ASSOCIATION示例
猜你喜欢

Redis connection error err auth < password > called without any password configured for the default user

SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)

SAP CR传输请求顺序、依赖检查

Super classic & Programming Guide (red and blue book) - Reading Notes

BTree、B+Tree和HASH索引

js之预解析

王者荣耀-unity学习之旅

设置了body的最大宽度,但是为什么body的背景颜色还铺满整个页面?

King glory - unity learning journey

超级宝典&编程指南(红蓝宝书)-读书笔记
随机推荐
Solutions to common problems in visualization (VII) solutions to drawing scale setting
Hot change scheme and dynamic update strategy of mobile game
9.常用函数
自定义时间格式(YYYY-MM-DD HH:mm:ss 星期X)
MySQL isolation level
系统与软件安全研究(二)
Django uses MySQL database to solve error reporting
Moment.js中format方法函数的格式
NPM installation stepping pit
SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)
层次输出二叉树
安装配置淘宝镜像npm(cnpm)
Understanding of STL container
系统与软件安全研究(三)
js之自定义属性以及H5中如何判断自定义属性
Redis connection error err auth < password > called without any password configured for the default user
面经总结2
页面动态显示时间(升级版)
SAP RFC_CVI_EI_INBOUND_MAIN BP主数据创建示例(仅演示客户)
Mysql 索引