摘要:
[C#动态调用C++编写的DLL函数] by jingzhongrong 2008-05-08动态加载DLL需要使用Windows API函数:LoadLibrary、GetProcAddress以及FreeLibrary。我们可以使用DllImport在C#中使用这三个函数。[DllImport("Kernel32")]public static extern int GetProcAddres... 阅读全文
随笔分类 - c#
判断是否有全屏程序正在运行(C#)
2010-03-22 20:55 by 观海看云, 612 阅读, 收藏, 编辑
摘要:
注册一个AppBar(什么是AppBar?Using Application Desktop Toolbars ),通过SHAppBarMessage向系统注册AppBar,这样,当有程序全屏运行时系统会向我们的程序发送消息,在窗体WndProc中处理即可。声明要使用到的API和常量:view plaincopy to clipboardprint?public class APIWrapper ... 阅读全文
C#对三种XML文件的读法
2010-03-22 20:52 by 观海看云, 411 阅读, 收藏, 编辑
摘要:
1. XML文件的读取1XML文件格式如下:<?xmlversion="1.0"encoding="utf-8"?><configure><configid="path"value="D:\新建文件夹" /></configure>//xml文件所在路径private readonly static string xmlFilePath = @"..... 阅读全文
C# 强行停止本地一个进程
2010-03-22 20:46 by 观海看云, 369 阅读, 收藏, 编辑
摘要:
运行这个程序之前要慎重考虑,因为关闭程序的方式是强制关闭。进程可在资源管理器中查到(不要后面的.exe,只写前面的名)string in_sAppName = "WINWORD"; //(一个word文档程序)try{ System.Diagnostics.Process[] psiNewcas = System.Diagnostics.Process.GetProcessesByName(in_... 阅读全文
C#转义符
2010-03-22 20:45 by 观海看云, 221 阅读, 收藏, 编辑
摘要:
转义符字符名\'单引号\"双引号\\反斜杠\0空字符\a感叹号(Alert)\b退格\f换页\n新行\r回车\t水平tab\v垂直tab 阅读全文
C#调用MD5算法就是这么简单!
2010-03-22 20:42 by 观海看云, 3140 阅读, 收藏, 编辑
摘要:
using System.Security.Cryptography; private static string MD5ToString(String argString) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] data = System.Text.Encoding.Default.GetBytes(argString); b... 阅读全文
C#判断输入的字符串中是否含有大写字母,小写字母,数字,字符
2010-03-22 20:39 by 观海看云, 3243 阅读, 收藏, 编辑
摘要:
System.Text.RegularExpressions.Regex.IsMatch(argValue, "[A-Z]") System.Text.RegularExpressions.Regex.IsMatch(argValue, "[0-9]") System.Text.RegularExpressions.Regex.IsMatch(argValue, "[a-z]") System.T... 阅读全文
C# 字符转ASCII码,ASCII码转字符
2010-03-22 20:33 by 观海看云, 607 阅读, 收藏, 编辑
摘要:
字符转ASCII码:public static int Asc(string character) { if (character.Length == 1) { System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding(); int intAsciiCode = (int)asciiEncoding.GetByt... 阅读全文
C# 快速关机代码
2010-03-22 20:32 by 观海看云, 4126 阅读, 收藏, 编辑
摘要:
今天用到这个,网上找个不错的,保存下来。注意:这个方法是快速关机,不会保存你的任何未保存信息。// 这个结构体将会传递给API。使用StructLayout [StructLayout(LayoutKind.Sequential, Pack = 1)] internal struct TokPriv1Luid { public int Count; public long Luid; ... 阅读全文
c# 窗体位置任意调
2010-03-22 20:24 by 观海看云, 434 阅读, 收藏, 编辑
摘要:
发现窗体的位置只能通过StartPosition属性设置,而这个属性只提供了5种位置选项,很不够!今天在网上找到了一个解决的方法,如下:int x= System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width/2;int y=System.Windows.Forms.Screen.PrimaryScreen.WorkingAre... 阅读全文
C# 遍历窗体上控件方法
2010-03-22 20:23 by 观海看云, 332 阅读, 收藏, 编辑
摘要:
foreach(Controlcinthis.Controls) { if(cisTextBox) { ((TextBox)c).Clear(); } elseif(cisLabel) { ~~~~~~ } } 阅读全文
TabControl添加关闭按钮
2010-02-24 20:58 by 观海看云, 1901 阅读, 收藏, 编辑
摘要:
const int CLOSE_SIZE = 4;Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--//清空控件this.MainTabControl.TabPages.Clear();//绘制的方式OwnerDrawFixed表示由窗体绘制大小也一样t... 阅读全文
窗体上有一个TreeView和若干个TextBox控件,我希望当点击treeview中的某个节点时能让指定的TextBox得到焦点。
2009-12-31 19:53 by 观海看云, 326 阅读, 收藏, 编辑
摘要:
用委托的异步来处理: private delegate void focusHandle();//定义委托 private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { focusHandle h = new focusHandle(f); h.Be... 阅读全文
DataGridViewComboBoxColumn 使用
2009-12-25 11:23 by 观海看云, 684 阅读, 收藏, 编辑
摘要:
用于编辑单元格时间时发生private void dgvBreed_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { EditingControl = e.Control; if (e.Control.GetType() == typeof(DataGridViewComboBo... 阅读全文