日期:2009-12-24 浏览次数:20404 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;
namespace WinIO驱动级模拟键盘
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
#region 驱动级键盘输入定义
//键盘输入
// public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
//[DllImport("User32.dll")]
//public static extern void keybd_event(Byte bVk, Byte bScan, Int32 dwFlags, Int32 dwExtraInfo);
//private const int KEYEVENTF_KEYUP = 2;
//winio开始
public const int KBC_KEY_CMD = 0x64;
public const int KBC_KEY_DATA = 0x60;
[DllImport("WinIo32.dll")]
public static extern bool InitializeWinIo();
[DllImport("WinIo32.dll")]
public static extern bool GetPortVal(IntPtr wPortAddr, out int pdwPortVal,
byte bSize);
[DllImport("WinIo32.dll")]
public static extern bool SetPortVal(uint wPortAddr, IntPtr dwPortVal,
byte bSize);
[DllImport("WinIo32.dll")]
public static extern byte MapPhysToLin(byte pbPhysAddr, uint dwPhysSize,
IntPtr PhysicalMemoryHandle);
[DllImport("WinIo32.dll")]
public static extern bool UnmapPhysicalMemory(IntPtr PhysicalMemoryHandle,
byte pbLinAddr);
[DllImport("WinIo32.dll")]
public static extern bool GetPhysLong(IntPtr pbPhysAddr, byte pdwPhysVal);
[DllImport("WinIo32.dll")]
public static extern bool SetPhysLong(IntPtr pbPhysAddr, byte dwPhysVal);
[DllImport("WinIo32.dll")]
&nb