C # store values in ini format (for example, the user name and logon number on the logon Interface ),
This is the first blog post. In the future, I will summarize and share all the things I have found through my own materials during development, so that I can take a look at them later ~~~
Ps: Of course, I feel like I am still a small dish ~ For the great gods, the content may be relatively simple ~ A lot of things are also sorted out on the Internet. It would be a great honor for me to help you a little bit.
First, if you have created a login interface, you must enter the "user name" [UserName] and password to log on. To avoid entering the user name every time you open the system, now we need to implement a file storage function,
The file will be stored in ". ini" format:
Write File:
1 [DllImport ("kernel32")] 2 private static extern long WritePrivateProfilesString (string section, string key, string val, string filepath); 3 private static void WriteToIni (string name, string key, string value) 4 {5 WritePrivateProfilesString (name, key, value, Directory. getCurrentDirectory () + @ "\ User. ini "); 6}WRITE
Read data from a file:
1 [DllImport ("kernel32")] 2 private static extern int GetPrivateProfileString (string section, string key, string def, StringBuilder returnval, int size, string iniPath ); 3 private string GetStringIni (string section, string key) 4 {5 StringBuilder strbuider = new StringBuilder (1024); 6 string def = null; 7 GetPrivateProfileString (section, key, def, strbuilder, 1024, Directory. getCurrentDirectory () + @ "\ User. ini "); 8 return strbuilder. toString (); 9}READ
In the C language, what is the symbol (->) and how to use it?
This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.
In the C language, what is the symbol (->) and how to use it?
This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.