小常识

发布时间:2024-11-10 23:11

小常识

最新推荐文章于 2021-11-17 16:29:10 发布

cyq 于 2014-07-31 10:49:20 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

1.程序中启动其他进程     

string path = Application.StartupPath + "\\**.exe";

Process.Start(path);

2.事件触发

private void ButtonClick(object sender, RoutedEventArgs e)

{

Button cmd = (Button)e.OriginalSource;

Type type = this.GetType();

Assembly assembly = type.Assembly;

Window win = (Window)assembly.CreateInstance(

type.Namespace + "." + cmd.Content);

win.ShowDialog();

}

3.ini配置文件读写类

using System;

using System.IO;

using System.Runtime.InteropServices;

using System.Text;

namespace Ini

{

public class IniFile

{

public string path;

[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);

public IniFile(string INIPath)

{

path = INIPath;

}

public void IniWriteValue(string Section, string Key, string Value)

{

WritePrivateProfileString(Section, Key, Value, this.path);

}

public string IniReadValue(string Section, string Key)

{

StringBuilder temp = new StringBuilder(255);

int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);

return temp.ToString();

}

}

}

4.CRC校验(多项式A001)http://download.csdn.net/detail/wohaorende/3597075

public string GetCRC(string DATA)

{

long functionReturnValue = 0;

long i = 0;

long J = 0;

byte[] v = null;

v = Encoding.ASCII.GetBytes(DATA);

long CRC = 0;

CRC = 0xffffL;

for (i = 0; i <= (v).Length - 1; i++)

{

CRC = (CRC / 256) * 256L + (CRC % 256L) ^ v[i];

for (J = 0; J <= 7; J++)

{

long d0 = 0;

d0 = CRC & 1L;

CRC = CRC / 2;

if (d0 == 1)

CRC = CRC ^ 0xa001L;

}

}

CRC = CRC % 65536;

functionReturnValue = CRC;

return string.Format("{0:X}", functionReturnValue);

}

网址:小常识 https://www.yuejiaxmz.com/news/view/26585

相关内容

【常识】日常生活小常识
护肤小常识? 日常护肤小常识?
心理健康知识小常识 15个小常识
[指南]生活小常识日常生活小常识
生活小常识? 生活急救小常识?
健康知识小常识? 健康知识与养生小常识?
育儿生活小常识? 幼儿育儿知识小常识?
美容护肤小常识(护肤1000个小常识)
日常生活健康小常识大全——生活小常识小窍门?
日常理财小常识

随便看看