易截截图软件、单文件、免安装、纯绿色、仅160KB

c# 程序只运行一次的处理方法

方法一:遍历正在有相同名字运行的例程
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DHPSS.COM
{
/// <summary>
/// c#程序只运行一次,C#例程只运行一次
/// http://blog.csdn.net/nnsword
/// QQ:16349023
/// </summary>
public class CHandleRunningPro
{
/// <summary>
/// const int, ShowWindowAsync 使用时的参数,让窗体正常显示确保没有隐藏和最小化。
/// </summary>
private const int WS_SHOWNORMAL = 1;
/// <summary>
/// 功能:遍历所有运行的例程,判断是否已经有相同名字的例程。
/// 实现:遍历所有运行的例程,如果有与自己名字相同的比较 ID 是否相同。
/// 如果ID不同说明已经有实例在运行,则把该实例返回。
/// 如果没有则返回 null
/// </summary>
/// <returns>有相同名字的例程返回其 process,否则返回null</returns>
private Process GetRunningInstance()
{
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(current.ProcessName);
//遍历正在有相同名字运行的例程
foreach (Process process in processes)
{
//忽略现有的例程
if (process.Id != current.Id)
{
return process;
}
}
//没有其它的例程,返回Null
return null;
}
//接下来调用两个WinAPI,其功能将在包装方法中描述,
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
//以上的方法声明为私有,对其进一步包装,


相关文档:

解析C#中is和as操作符的用法

c# 中 is和as 操作符是用来进行强制类型转换的
is : 检查一个对象是否兼容于其他指定的类型,并返回一个Bool值,永远不会抛出异常
object o = new object();
if (o is Label)
{
Label lb = (Label)o;
Response.Write("类型转换成功");
}
else
{
Response.Write(" ......

C#中用SYSTEM.XML读写XML说明与代码

<?xml version="1.0" encoding="utf-8"?>
<LinkLibrary xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Link Cat="aa" Url="aa" Desc="aa" />
<Link Cat="bb" Url="aa" Desc="aa" />
<Link Cat="cc" Url="aa" Desc="aa" />
&l ......

asp.net(c#) 返回上一页

摘抄前辈们的
其实要实现这个功能主要还是要用到javascript
方法一:
在asp.net的aspx里面的源代码中
<input type="button onclick="javascript:window.history.go(-1);"value="返回上一页">
浅析:这个是用了HTML控件,通过一个onclick的事件,调用了javascript中的一个方法就可以了。这个是最简单的了,也同样 ......

在C#.net中如何操作XML


在C#.net中如何操作XML
在C#.net中如何操作XML
可能很多朋友还没有进行过XML操作,希望下面这篇文章能对大家有帮助.或者自己复制一下代码试一下.这篇文章不是我写的.我只是转过来.觉得不错.
需要添加的命名空间:
using System.Xml;
定义几个公共对象:
XmlDocument xmldoc ;
XmlNode xmlnode ;
XmlElement xmlele ......

c# asp.net 字符串加密解密的类


using System;   
using System.Collections.Generic;   
using System.Text;   
using System.Security.Cryptography;//Cryptography密码术   
namespace DAL   
{   
    public class Enc ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号