当前位置:网站首页>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
边栏推荐
猜你喜欢
SAP DEBUG调试FOR IN、REDUCE等复杂的语句
Django使用mysql数据库报错解决
Nacos / sentinel gateway current limiting and grouping (code)
SAP PI / Po rfc2restful Publishing RFC interface as restful examples (proxy indirect)
‘npm‘不是内部或外部命令,也不是可运行的程序 或批处理文件
SAP PI/PO rfc2RESTful 发布rfc接口为RESTful示例(Proxy间接法)
Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
int a = 1存放在哪
ABAP 实现发布RESTful服务供外部调用示例
FSM finite state machine
随机推荐
页面实时显示当前时间
游戏辅助脚本开发之旅
3. Sort statement
new的实现
Super classic & Programming Guide (red and blue book) - Reading Notes
SAP Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃。
js之函数的两种声明方式
F-牛妹的苹果树(直径合并)
Django使用mysql数据库报错解决
2022.3.14 Ali written examination
How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)
SAP PI/PO rfc2RESTful 發布rfc接口為RESTful示例(Proxy間接法)
int a = 1存放在哪
Mobile game performance optimization
SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)
移动端布局(3D转换、动画)
js之节点操作,为什么要学习节点操作
3.排序语句
异步的学习
配置npm