Two functions for reading and writing INI files
Writeprivateprofilestring (); // write
Writeprivateprofilestring (string section, string key, string Val, string filepath );
Parameter description
Section summary name
Key keyword
Val Value
Filepath
Getprivateprofilestring (); // read
Getprivateprofilestring (string section, string key, string def, stringbuilder retval, int size, string filepath );
Parameter description
Section summary name
Key keyword
Default Value returned when the def specified entry is not found
Character Buffer specified by retval
Size retval maximum number of characters in the buffer
Filepath
You need to introduce
Using system. runtime. interopservices;
Code Example Code
[Dllimport ( " Kernel32 " )]
Private Static Extern Long Writeprivateprofilestring ( String Section, String Key, String Val, String Filepath );
Private Void Button3_click ( Object Sender, eventargs E)
{
Writeprivateprofilestring ( " Feng " , " ID " , " 007 " , @" D: \ FSL. ini " );
Writeprivateprofilestring ( " Feng " , " ISS " , " 008 " , @" D: \ FSL. ini " );
Writeprivateprofilestring ( " F " , " ID " , " 008 " , @" D: \ FSL. ini " );
}
[Dllimport ( " Kernel32 " )]
Private Static Extern Int Getprivateprofilestring ( String Section, String Key, String Def, stringbuilder retval, Int Size, String Filepath );
Private Void Button4_click ( Object Sender, eventargs E)
{
Stringbuilder temp = New Stringbuilder ();
Getprivateprofilestring ( " Feng " , " ID " , " Dddddxxxd " , Temp, 255 , @" D: \ FSL. ini " );
Label1.text = Temp. tostring ();
}