You can call two APIs in kernel32.dll: writeprivateprofilestring and getprivateprofilestring to read INI files.
The specific implementation code 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;
Public Void Iniwritevalue ( String Section, String Key, String Value, String Filepath) // The write operation on the INI file.
{
Writeprivateprofilestring (section, key, value, filepath );
}
Public String Inireadvalue ( String Section, String Key, String Filepath) // A function used to read an INI file.
{
Stringbuilder temp= NewStringbuilder (255);
IntI=Getprivateprofilestring (section, key,"", Temp,
255, Filepath );
ReturnTemp. 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