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

C#单实例运行的实现

主要通过修改program.cs文件的内容来实现。
首先在添加几个名空间的引用:
using System.Diagnostics;                          //使用Process
using System.Runtime.InteropServices;     //使用DllImport
using System.Reflection;                            //使用Assembly
然后在引入系统API :
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private const int WS_SHOWNORMAL = 1;
再添加几个成员函数:
        public static Process GetPreIns()
        {//获取当前进程句柄
            Process cur= Process.GetCurrentProcess();
            Process[] procs = Process.GetProcessesByName(current.ProcessName);               
            foreach (Process proc in procs )
            { //遍历,以获取前一实例的句柄                     
                if (proc .Id != cur.Id) //忽略现有的例程
                {
                    //确保例程从EXE文件运行   


相关文档:

C# word转换成HTML

C# word转换成HTML
添加com引用Microsoft word 11.0 Object Library
添加using System.Threading;using System.IO;
       //实例化一个Word
        Microsoft.Office.Interop.Word.ApplicationClass appclass = new Microsoft.Office.Inter ......

C#(ASP.NET) 下载数据

Internet 类
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
namespace DownData
{
    class internet
    {
 &nb ......

Paging long articles in ASP.NET using C#

Paging long articles in ASP.NET using C#
Long articles are better broken into bite-sized chunks over several pages. With static HTML, this is easily achieved by dividing the article into logical separations and creating separate .htm files for each. Here's how to do it using C# for an article that ......

在C#中运用 SQLite

  SQLite 是一个嵌入式的联系数据库系统,运用十分广泛。在一些数据量不大的运用 程序中,假如运用 SQLite可以极大的降低部署时的工作量。 要在C#中运用 SQLite也很基本,只要找一个C#的wrapper就可以了,例如,我运用的就是来自
  http://sqlite.phxsoftware.com/  的一个dll,System.Data.SQLite. 下载下来的文件是 ......

C# 创建Access数据库表

using System;
using System.IO;
using System.Windows.Forms;
using Access = Microsoft.Office.Interop.Access;
// 添加引用->.NET-> dao,Microsoft.Office.Interop.Access
namespace WinFormAccess
{
    public partial class FormAccess : Form
    {
  &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号