扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:陈琦 来源:yesky 2007年10月15日
关键字: Visual Basic I/O 端口控制
#include #include /*作用:从指定端口读入一个字节 参数:portid端口号 返回值:读入的字节*/ int _stdcall Inport(short portid) { return inp(portid);} /*作用:向指定端口写入一个字节 参数:portid端口号*/ void _stdcall output(short portid,short byte) { outp(portid,byte); } /*作用:从指定端口读入一个字节 参数:portid端口号 返回值:读入的字节*/ int _stdcall Inportw(short portid) { return inpw(portid);} /*作用:向指定端口写入一个字节 参数:portid端口号*/ void _stdcall Outportw(short portid,short word) { outpw(portid,(unsigned short) word); } |
Sub pictrue1-DragDrop(Source as Control,X as Single,Y as Single) Pictrue1.DrawWidth=6 picture1.pset(x,y),QBcolor(4) End Sub |
DragOver(Source as conterol,X as Single,Y as Single,State as Integer) |
Declare Function GetDriveType Lib "kernel32" Alias _ "GetDriveTypeA" (ByVal nDrive As String) As Long |
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Const WH_KEYBOARD = 2 Public Const KBH_MASK = &H20000000 Public Const WM_LBUTTONDOWN = &H201 Public Const WM_LBUTTONUP = &H202 Global hHook As Long 'KeyboardProc 在 VB 应用动作前发生 Public Function KeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If nCode >= 0 Then '处理你希望过滤的键 If wParam = Asc("C") And (lParam And KBH_MASK) <> 0 Then If (lParam And &HC0000000) = 0 Then '模拟在Command1 中单击 Form1.Command1.SetFocus Call PostMessage(Form1.Command1.hwnd, WM_LBUTTONDOWN, 0, &H20002) Call PostMessage(Form1.Command1.hwnd, WM_LBUTTONUP, 0, &H20002) KeyboardProc = 1 Exit Function End If End If End If KeyboardProc = CallNextHookEx(hHook, nCode, wParam, lParam) End Function Private Sub Form_Load() '将 KeyboardProc 连接到中断上 hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf KeyboardProc, 0&, App.ThreadID) End Sub Private Sub Form_Unload(Cancel As Integer) Call UnhookWindowsHookEx(hHook) End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者