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);
//以上的方法声明为私有,对其进一步包装,
相关文档:
摘抄前辈们的
其实要实现这个功能主要还是要用到javascript
方法一:
在asp.net的aspx里面的源代码中
<input type="button onclick="javascript:window.history.go(-1);"value="返回上一页">
浅析:这个是用了HTML控件,通过一个onclick的事件,调用了javascript中的一个方法就可以了。这个是最简单的了,也同样 ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//sqlserver身份验证
//string sqlconn = "ser ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//sqlserver身份验证
//s ......
本文将介绍C#项目打包以及自动安装SQL Sever数据库,包括创建部署项目、将主程序项目的输出添加到部署项目中、创建安装程序类、创建自定义安装对话框等等。
’power by: landlordh
’for 2000,xp,2003
Module uninstall
Sub Main ......
产品几年前使用ASP,后来升级到.Net 1.1,再升级到2.0,一直都有用XSLT转换XML生成网页的方式,稍微整理下。
XML file:
<?xml version="1.0" encoding="utf-8" ?>
<ric>
<catalog>
<book price ......