You can read the INI file by calling the two api:writeprivateprofilestring,getprivateprofilestring in Kernel32.dll.
The code for the implementation is as follows:
Using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;
Using System.Runtime.InteropServices;
Using System.Text;
Namespace Iniprocess
{
public class Form1:System.Windows.Forms.Form
{
Private System.Windows.Forms.TextBox TextBox1;
Private System.Windows.Forms.Button button2;
Private System.Windows.Forms.Button button1;
[DllImport ("kernel32")]
private static extern long WritePrivateProfileString (string section,
String key,string val,string FilePath);
[DllImport ("kernel32")]
private static extern int getprivateprofilestring (string section,
String Key,string def, StringBuilder RetVal,
int size,string filePath);
function for write to INI file by public void Iniwritevalue (string section,string key,string value,string filepath)/
{
WritePrivateProfileString (Section,key,value,filepath);
}
The function of the public string Inireadvalue (string section,string key,string filepath)//To read the INI file
{
StringBuilder temp = new StringBuilder (255);
int i = getprivateprofilestring (Section,key, "", temp,
255, filepath);
Return temp. ToString ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service