07 2009 档案

C# GET、POST方式请求web
摘要: private string GetModel(string strUrl) { string strRet = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl); request.Timeout = 2000; HttpWebResponse response = (HttpWebResp...阅读全文

posted @ 2009-07-22 08:38 笨笨真笨 阅读(215) | 评论 (0) 编辑

C# Url传递中文 转义编码
摘要: 百度的编码System.Web.HttpUtility.UrlEncode( "中文 ", System.Text.UnicodeEncoding.GetEncoding( "GB2312 ")).ToUpper()Google的编码System.Web.HttpUtility.UrlEncode( "中文 ")得到值System.Web.HttpUtility.UrlDecode( "%BA%A...阅读全文

posted @ 2009-07-22 07:42 笨笨真笨 阅读(1043) | 评论 (2) 编辑

C#中如何去除或屏蔽窗体默认的关闭按钮
摘要: 很多时候,在winform的设计下,会遇到新建窗体时不需要用到默认的关闭按钮的情况,而是用另外设置关闭 button或其他控件来控制窗体的关闭。 之前我遇到这个问题时,问了很多朋友,都没找到方法,VS的窗体属性里也没那一项,在MSDN里也没有相关的资料。 但后来偶然发现,原来办法是很简单的,只需要在初始化窗体的时候不显示那关闭按钮就可以了。 具体方法是,加上一句 “ this.Cont...阅读全文

posted @ 2009-07-16 23:49 笨笨真笨 阅读(682) | 评论 (0) 编辑

c#怎么捕捉非窗体上的鼠标事件
摘要: 全局钩子 public class HookMessage { private IntPtr m_HookEx; /// <summary> /// 设置自己进程的钩子 /// </summary> /// <param name="p_HookCodes">钩子类型 </param> public HookMessage(WindowsHookCo...阅读全文

posted @ 2009-07-16 21:54 笨笨真笨 阅读(383) | 评论 (0) 编辑

c# Settings.settings 设置
摘要: 1、定义在Settings.settings文件中定义配置字段。把作用范围定义为:User则运行时可更改,Applicatiion则运行时不可更改。可以使用数据网格视图,很方便;2、读取配置值text1.text = Properties.Settings.Default.FieldName;//FieldName是你定义的字段3、修改和保存配置Properties.Settings.Defaul...阅读全文

posted @ 2009-07-10 19:27 笨笨真笨 阅读(561) | 评论 (0) 编辑

C# Winform 只能运行一个实例
摘要: 这里列举了比较常见的方法:1、static void Main() { bool initiallyOwned = true; bool isCreated; Mutex m = new Mutex(initiallyOwned,"MyTest",out isCreated); if (!(initiallyOwned && isCreated)) { MessageBox.Sho...阅读全文

posted @ 2009-07-10 17:53 笨笨真笨 阅读(427) | 评论 (0) 编辑

截取图片的某个部分(C#源代码)
摘要: 方法一(get/set pixel)核心语句:resultBitmap.SetPixel(x, y, sourceBitmap.GetPixel(offsetX + x, offsetY+y)) /// <summary> /// get a certain rectangle part of a known graphic /// </summary> /// <p...阅读全文

posted @ 2009-07-10 17:29 笨笨真笨 阅读(211) | 评论 (0) 编辑

C# 图片取色程序
摘要: usingSystem;usingSystem.Diagnostics;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingbitmapTest.Propertie...阅读全文

posted @ 2009-07-10 17:15 笨笨真笨 阅读(218) | 评论 (1) 编辑

c# 识别验证码
摘要: using System;using System.Collections.Generic;using System.Text;using System.Net;using System.Web;using System.Drawing;using System.Drawing.Imaging;namespace PcRegister{ /**//// <summary> /// Cr...阅读全文

posted @ 2009-07-10 16:46 笨笨真笨 阅读(527) | 评论 (0) 编辑

C#中时间差的计算
摘要: 程序代码: label1.Text = "2004-1-1 15:36:05";label2.Text = "2004-3-1 20:16:35"; DateTime d1 =new DateTime(2004,1,1,15,36,05); DateTime d2 =new DateTime(2004,3,1,20,16,35); TimeSpan d3 = d2.Subtract(d1); ...阅读全文

posted @ 2009-07-08 00:22 笨笨真笨 阅读(345) | 评论 (0) 编辑