随笔分类 -  编程

摘要:有时候可能会用到,给数据库连接的字符串加密,让人不那么容易看出服务器的地址和帐号信息,所以大家可以用这个工具,把字符串加密,然后执行的时候解码,就可以了。方便实用。using System;using System.Collections.Generic;using System.Text;namespace StringEncry{ class EncodeAndDecode { /// <summary> /// Base64加密 /// </summary> /// <param name="codeName">加密采用... 阅读全文
posted @ 2012-08-15 11:01 StupidsCat 阅读(12231) 评论(1) 推荐(0) 编辑
摘要:用VS建立一个windows项目,取名test引用dll文件编写代码,正常引用dll里的类库,同时在test项目添加资源文件(该文件就是刚才引用的dll文件)VS会自动生成引用代码,我这里引用的是IrisSkin2.dllview plain internal static byte[] IrisSkin2 { get { object obj = ResourceManager.GetObject("IrisSkin2", resourceCulture); return ((byte[])(obj)); } } 然后在Main(program.cs)函数里加入代码sta 阅读全文
posted @ 2012-08-09 13:03 StupidsCat 阅读(3406) 评论(0) 推荐(0) 编辑
摘要:以下是C#代码,可以直接复制使用。using System;using System.Collections.Generic;using System.Text;using System.Management;namespace PingMock{ class MockerClass { private static Object thisobject = new Object(); public void Ping(string Host) { //string rtn = ""; ... 阅读全文
posted @ 2012-08-02 10:39 StupidsCat 阅读(943) 评论(0) 推荐(0) 编辑
摘要:给自己的程序,加上记录日志的功能。以下是C#代码,可以直接复制使用的。using System;using System.Collections.Generic;using System.Text;using System.IO;namespace PingMock{ class LogClass { /**//// <summary> /// 写入日志文件 /// </summary> /// <param name="input"></param> public void WriteLogFile(... 阅读全文
posted @ 2012-08-02 10:35 StupidsCat 阅读(27674) 评论(3) 推荐(2) 编辑
摘要:前言在网络编程中,通过广播和多播可以实现发送端发送一个数据包,有多个接收端接收的情况。广播由于Tcp是有连接的,所以不能用来发送广播消息。发送广播消息,必须用到Udp,Udp可以不用建立连接而发送消息。广播消息的目的IP地址是一种特殊IP地址,称为广播地址。广播地址由IP地址网络前缀加上全1主机后缀组成,如:192.168.1.255是192.169.1.0这个网络的广播地址;130.168.255.255是130.168.0.0这个网络的广播地址。向全部为1的IP地址(255.255.255.255)发送消息的话,那么理论上全世界所有的联网的计算机都能收得到了。但实际上不是这样的,一般路由器 阅读全文
posted @ 2012-07-31 13:42 StupidsCat 阅读(2941) 评论(0) 推荐(0) 编辑
摘要:今天研究了一下,在C#里面却是可以不用自定义消息这么复杂的方法来实现跨窗体调用控件,C#有更好的办法就是委托。效果描述:有两个窗体,FORM1(一个名为“打开form2”的button控件)和FORM2(一个名为“改变form1颜色“的button控件)。启动时,FORM1中点击button控件“打开form2””使FORM2显示出来。点击FORM2中的“改变form1颜色”后,Form1中颜色改变。一、在Form2里面: 首先声明一个委托和委托实例Form2类外[csharp]view plaincopypublicdelegatevoidChangeFormColor(booltopmos 阅读全文
posted @ 2012-07-19 11:44 StupidsCat 阅读(6141) 评论(0) 推荐(0) 编辑
摘要:通过C#发送邮件,可以根据自己的需求更改。这个是个配置文件的类,可以用,也可以改,也可以不用。using System;using System.IO;using System.Runtime.Serialization.Formatters.Binary;namespace WaterCubeCheck{ [Serializable] public class dataStruct//配置结构 { public string mingcheng1 = "服务器1", mingcheng2 = "服务器... 阅读全文
posted @ 2012-06-15 15:47 StupidsCat 阅读(16512) 评论(1) 推荐(3) 编辑
摘要:获取本地 有线 正在使用的网卡信息包括 IP 掩码 网关 DNS服务地址 网卡地址 网卡名称等信息代码如下C# Code:using System.Management; private void GetCurrentInfo() { ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'"); ... 阅读全文
posted @ 2012-06-06 11:35 StupidsCat 阅读(1088) 评论(6) 推荐(0) 编辑
摘要:1. 用Type 在 website 下C#代码 //定义参数类型数组 Type[] tps = new Type[2]; tps[0] = typeof(int); tps[1] = typeof(string); //定义参数数组 object[] obj = new object[2]; obj[0] = (object)100; obj[1] = (object)"Param Example"; string UserDaoPath = System.Configuration.ConfigurationSettings.AppSettings["User 阅读全文
posted @ 2012-05-31 14:50 StupidsCat 阅读(7558) 评论(0) 推荐(0) 编辑
摘要:为自己写的程序加一个注册功能吧。生成的机器号是根据CPU和硬盘号来的,根据自己的需求改成是否是随机生成。 代码直接粘贴到新建类覆盖原代码就能直接用了。using System;using System.Management;using System.Security.Cryptography;using System.Text;namespace RegisterClass{ class RegisterClass { //步骤一: 获得CUP序列号和硬盘序列号的实现代码如下: //获得CPU的序列号 bool Stupids = t... 阅读全文
posted @ 2012-05-29 16:27 StupidsCat 阅读(19839) 评论(9) 推荐(3) 编辑