1 DLLImport的使用 using System; using System.Runtime.InteropServices; //命名空间 class Example { //用DllImport 导入Win32的MessageBox函数 [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern int MessageBox(IntPtr hWnd, String text, S
类文件: C#类文件 using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Reflection; namespace Common { public class BardCodeHooK { public delegate void BardCodeDeletegate(BarCodes barCode); pub
首先建一个类,比如NativeMethods.cs class NativeMethods{ public const int WS_CAPTION=0x00C0000; public const int WS_BORDER=0x00800000; public const int WS_DLGFRAME=0x00400000; public const int GWL_STYLE=-16; [DllImport("user32", EntryP
1.调用GetAsyncKeyState()获取指定按键的状态,GetActiveKey()检索指定范围内的按键状态 2.调用keybd_event()可合成一次击键事件,通常两次击键事件间需要设定时间间隔 3.调用MapVirtualKey()获取指定按键的硬件扫描码,传入keybd_event()第二个参数就可以对DirectInput有效. Public Class ImitateKeyClass Private Declare Sub keybd_event Lib "user32&qu