当前位置:网站首页>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
边栏推荐
- 1. View databases and tables
- On BFC (block formatting context)
- Solutions to common problems in visualization (VII) solutions to drawing scale setting
- Reflection on the systematic design of Android audio and video caching mechanism
- [Ted series] how to get along with inner critics?
- 12. Constraints
- 数组扁平化
- h5本地存储数据sessionStorage、localStorage
- ‘npm‘不是内部或外部命令,也不是可运行的程序 或批处理文件
- 配置npm
猜你喜欢
js之节点操作,为什么要学习节点操作
SAP PI/PO rfc2Soap 发布rfc接口为ws示例
js之DOM事件
SAP RFC_CVI_EI_INBOUND_MAIN BP主数据创建示例(仅演示客户)
Solutions to common problems in visualization (VII) solutions to drawing scale setting
MySQL index
SAP pi / PO rfc2soap publishes RFC interface as WS example
Design optimization of MySQL database
BTREE, B + tree and hash index
ABAP 从CDS VIEW 发布OData Service示例
随机推荐
7.子查询
MySQL isolation level
2022.3.14 Ali written examination
Learn to use search engines
8. Paging query
SAP PI/PO Soap2Proxy 消费外部ws示例
如何判断点是否在多边形内(包含复杂多边形或者多边形数量很多的情况)
SAP RFC_CVI_EI_INBOUND_MAIN BP主数据创建示例(仅演示客户)
Mvcc (multi version concurrency control)
js之函数的两种声明方式
Solutions to common problems in visualization (VII) solutions to drawing scale setting
Hot change scheme and dynamic update strategy of mobile game
【自我激励系列】你永远不会准备好
Implementation of MySQL persistence
js之DOM学习三种创建元素的方式
On BFC (block formatting context)
MySQL index
3. Sort statement
Custom time format (yyyy-mm-dd HH: mm: SS week x)
BTree、B+Tree和HASH索引