vb.netalias的简单介绍( 二 )


要使用序号来声明DLL过程,Alias子句中的字符串需要包含过程的序号,并在序号的前面加一个数字标记字符(#) 。例如,Windowskernel中的GetWindowsDirectory函数的序号为432;可以用下面的语句来声明该DLL过程:
Declare Function GetWindowsDirectory Lib "kernel32" _
Alias "#432" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
在这里,可以使用任意的合法名称作为过程的名称,VB将用序号在DLL中寻找过程 。
vb.net编写的程序屏蔽系统热键使用VB.net编写屏蔽热键的方法有很多中,比如说使用系统的API函数,也可以使用钩子来进行屏蔽.还有一种就是.net带的一种方法,首先来判断所按下去的键,然后再执行操作等事件.比如说:if (e.keycode==keys.D){e.handle=true}在keydown事件里面处理!这样就可以屏蔽了D键. 实例:if ((Control.ModifierKeys == Keys.Alt)(e.KeyCode == Keys.F4))
{
e.Handled = true;
}还有一种办法就是不通过屏蔽热键来实现,就是通过设置焦点.你可以把你程序窗口设置为主焦点,这样其他程序一般就无法在你的程序前面了.实现屏蔽的作用.至于任务管理器的话可以通过杀掉进程的办法做到.如下:Process[] p = Process.GetProcesses();foreach (Process p1 in p)
{
try
{
if (p1.ProcessName.ToLower().Trim() == "taskmgr")//这里判断是任务管理器
{
p1.Kill();
return;
}
}
catch
{
return;
}
}}以上是使用C#编写的,稍微改下就可以了,在,NET里面都差不多!
VB.net 怎么制作按键连发功能用API函数 , 以下代码Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate Const WS_EX_LAYERED = H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = H2
Private Const LWA_COLORKEY = H1Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMosT = -1
Private Const SWP_NOMOVE = H2
Private Const SWP_NosIZE = H1
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_KEYDOWN = H100
Const WM_KEYUP = H101
Const WM_CHAR = H102
Const VK_F1 = H70
Private Sub SendF1(hwnd)'调用这个过程即可对目标窗体发送F1键
Call PostMessage(hwnd, WM_KEYDOWN, VK_F1, 0)
Call PostMessage(hwnd, WM_KEYUP, VK_F1, 0)
End Sub这里是发送F1的实例,各个按键对应的虚拟键码,要到网上查
简单的播放器用vb.net怎么做啊右击工具箱/部件/WindowsMediaPlayer
//类模块Mmedia
Option Explicit
'-----------------------------------------------------
'Name:MMedia.cls
'Author:Peter Wright, For BG2VB4BG2VB5
'
'Notes:A multimedia class, which when turned
':into an object lets you load and play
':multimedia files, such as sound and
':video.
'-----------------------------------------------------
' -=-=-=- PROPERTIES -=-=-=-
' FilenameDetermines the name of the current file
' LengthThe length of the file (Read Only)
' PositionThe current position through the file
' StatusThe current status of the object (Read Only)
' WaitTrue/False...tells VB to wait until play done

推荐阅读