我在VS2005 下不能运行
全部代码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace WindowSAPplication2
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;
  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }
  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null) 
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }
  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.label1 = new System.Windows.Forms.Label();
   this.label2 = new System.Windows.Forms.Label();
   this.label3 = new System.Windows.Forms.Label();
   this.label4 = new System.Windows.Forms.Label();
   this.label5 = new System.Windows.Forms.Label();
   this.SuspendLayout();
   // 
   // label1
   // 
   this.label1.AutoSize = true;
   this.label1.Location = new System.Drawing.Point(49, 37);
   this.label1.Name = "label1";
   this.label1.Size = new System.Drawing.Size(83, 12);
   this.label1.TabIndex = 0;
   this.label1.Text = "EoS.3tion制作";
   // 
   // label2
   // 
   this.label2.AutoSize = true;
   this.label2.Location = new System.Drawing.Point(49, 64);
   this.label2.Name = "label2";
   this.label2.Size = new System.Drawing.Size(65, 12);
   this.label2.TabIndex = 1;
   this.label2.Text = "使用方法:";
   // 
   // label3
   // 
   this.label3.AutoSize = true;
   this.label3.Location = new System.Drawing.Point(65, 85);
   this.label3.Name = "label3";
   this.label3.Size = new System.Drawing.Size(155, 12);
   this.label3.TabIndex = 2;
   this.label3.Text = "1、将序列号拷贝到剪切板。";
   // 
   // label4
   // 
   this.label4.AutoSize = true;
   this.label4.Location = new System.Drawing.Point(65, 107);
   this.label4.Name = "label4";
   this.label4.Size = new System.Drawing.Size(179, 12);
   this.label4.TabIndex = 3;
   this.label4.Text = "2、将光标定位到序列号输入处。";
   // 
   // label5
   // 
   this.label5.AutoSize = true;
   this.label5.Location = new System.Drawing.Point(65, 128);
   this.label5.Name = "label5";
   this.label5.Size = new System.Drawing.Size(77, 12);
   this.label5.TabIndex = 4;
   this.label5.Text = "3、按F10键。";
   // 
   // Form1
   // 
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(292, 266);
   this.Controls.Add(this.label5);
   this.Controls.Add(this.label4);
   this.Controls.Add(this.label3);
   this.Controls.Add(this.label2);
   this.Controls.Add(this.label1);
   this.Name = "Form1";
   this.Text = "SN输入工具(C#版Version0.1)";
   this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
   this.Load += new System.EventHandler(this.Form1_Load);
   this.ResumeLayout(false);
   this.PerformLayout();
  }
  #endregion
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main() 
  {
   Application.Run(new Form1());
  }
  [DllImport("user32.dll", SetLastError=true)] 
  public static extern bool ReGISterHotKey( IntPtr hWnd, 
   // handle to window 
   int id, // hot key identifier 
   KeyModifiers fsModifiers, // key-modifier options 
   Keys vk // virtual-key code 
  ); 
  [DllImport("user32.dll", SetLastError=true)] 
  public static extern bool UnregisterHotKey( IntPtr hWnd,
   // handle to window 
   int id // hot key identifier 
  );
  [Flags()] 
  public enum KeyModifiers 
  { 
   None = 0, 
   Alt = 1, 
   Control = 2, 
   Shift = 4, 
   Windows = 8 
  }
  private void ProcessHotkey()//主处理程序
  {
   strKeys = CliPBoard.GetText();
   strKeys.Replace("-", "{TAB}");
   SendKeys.Send(strKeys);
  }
  private Label label1;
  private Label label2;
  private Label label3;
  private Label label4;
  private Label label5;
string strKeys;
  private void Form1_Load(object sender, System.EventArgs e)
  {
   label2.AutoSize = true;
   Clipboard.Clear();//先清空剪贴板防止剪贴板里面先复制了其他内容
   RegisterHotKey(Handle, 100, 0, Keys.F10);
  }
  private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  {
   UnregisterHotKey(Handle, 100);//卸载快捷键
  }
  protected override void WndProc(ref Message m)//循环监视Windows消息
  {
   const int WM_HOTKEY = 0x0312;//按快捷键
   switch (m.Msg)
   {
    case WM_HOTKEY:
     ProcessHotkey();//调用主处理程序
     break;
   }
   base.WndProc(ref m);
  }
 }
} 



 
											





 
	    

 
	



