C # video Surveillance series (15): Summary paste--Possible use of C # WinForm Technology Summary

Source: Internet
Author: User
Tags ini int size

Body

1.IntPtr converted into byte[]

public byte[] ConvertToBytes(IntPtr dataBuf, int length)
{
byte[] byteBuf = new byte[length];
Marshal.Copy(dataBuf, byteBuf, 0, length);
return byteBuf;
}

2. Read and write INI file

Generally used to read and write configuration files

<summary>
Read and write INI file
</summary>
public class IniFile
{
<summary>
File ini Name
</summary>
public string Path;

<summary>
Declaring API functions for reading and writing INI files
</summary>
<param name= "section" ></param>
<param name= "Key" ></param>
<param name= "Val" ></param>
<param name= "FilePath" ></param>
<returns></returns>
[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);

<summary>
Class, passing the INI file name
</summary>
<param name= "IniPath" ></param>
Public IniFile (String inipath)
{
//
Todo:add constructor Logic here
//
Path = IniPath;
}

<summary>
Write INI file
</summary>
<param name= "section" ></param>
<param name= "Key" ></param>
<param name= "Value" ></param>
public void Iniwritevalue (string section, String Key, String Value)
{
WritePrivateProfileString (section, Key, Value, this.) Path);

}

<summary>
Reading the INI file specifies
</summary>
<param name= "section" ></param>
<param name= "Key" ></param>
<returns></returns>
public string Inireadvalue (string section, String Key)
{
StringBuilder temp = new StringBuilder (5000);
int i = getprivateprofilestring (section, Key, "", temp, 5000, this. Path);
Return temp. ToString ();

}
}

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.