暴米花 发表于 2006-12-12 11:47:00

vb一些的入门知识

<strong><br/><br/></strong>以下是用VB做外挂的一些知识.我个人认为是入门的一些知识.不敢独享.贴出来给大家!~<br/>有时间随时补充~呵呵<br/><font color="#cc6600">&nbsp;1.查找目标窗口.需要做外挂,就需要查找目标窗口.然后才做一些其他的动作.比如说鼠标键盘模拟啦.内存修改啦.封包型发送与替换啦什么什么的</font><br/>-------------------------------------------------------------------------------------------------<br/>'定义模块<br/>Declare&nbsp;Function&nbsp;FindWindow&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"FindWindowA"&nbsp;(ByVal&nbsp;lpClassName&nbsp;As&nbsp;String,&nbsp;ByVal&nbsp;lpWindowName&nbsp;As&nbsp;String)&nbsp;As&nbsp;Long<br/>'在窗口中建立一timer(时间控制器),然后在代码窗口输入如下代码:<br/>Private&nbsp;Sub&nbsp;Form_Load()<br/>Timer1.Interval&nbsp;=&nbsp;500<br/>End&nbsp;Sub <p></p><p>时间控制器的代码如下:<br/>Private&nbsp;Sub&nbsp;Timer1_Timer()<br/>&nbsp;Dim&nbsp;hwnd&nbsp;As&nbsp;Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hwnd&nbsp;=&nbsp;FindWindow(vbNullString,&nbsp;"计算器")&nbsp;'抓取"计算器"这个窗口名称.<br/>If&nbsp;(hwnd&nbsp;=&nbsp;0)&nbsp;Then<br/>&nbsp;&nbsp;If&nbsp;MsgBox("你没有打开[计算器]程序!点击“确定”退出。点“取消”继续。",&nbsp;49,&nbsp;"错误!")&nbsp;=&nbsp;1&nbsp;Then&nbsp;End<br/>ElseIf&nbsp;(hwnd&nbsp;&lt;&gt;&nbsp;0)&nbsp;Then<br/>MsgBox&nbsp;"你已经打开了[计算器]程序.点“确定”退出本程序",&nbsp;,&nbsp;"退出"<br/>End<br/>End&nbsp;If<br/>End&nbsp;Sub</p>

暴米花 发表于 2006-12-12 11:47:00

<strong>模拟键盘事件<br/><br/></strong><font color="#cc6600">2.以下为模拟键盘事件.比如模拟"r"键.</font><br/>----------------------------------------------------------------------------------------------------------------------------<br/>&nbsp;'在模块中定义&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;Public&nbsp;Declare&nbsp;Sub&nbsp;keybd_event&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;bVk&nbsp;As&nbsp;Byte,&nbsp;ByVal&nbsp;Scan&nbsp;As&nbsp;Byte,&nbsp;ByVal&nbsp;dwFlags&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;dwExtraInfo&nbsp;As&nbsp;Long)&nbsp; <p></p><p>在窗口中建立一timer.时间间隔随意.只要不是0就可以了哦.呵呵.<br/>Private&nbsp;Sub&nbsp;Timer1_Timer()<br/>Call&nbsp;keybd_event(82,&nbsp;0,&nbsp;0,&nbsp;0)&nbsp;'模拟按下"R"键<br/>End&nbsp;Sub</p>

暴米花 发表于 2006-12-12 11:48:00

<strong>快捷键例子<br/><br/></strong><font color="#cc6600">3.以下为快捷键例子.比如按下"ctrl+A"就退出!</font><br/>'可以设置Form的KeyPreview属性为True,然后在Form_KeyDown事件中添加代码:&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;Private&nbsp;Sub&nbsp;Form_KeyDown(KeyCode&nbsp;As&nbsp;Integer,&nbsp;Shift&nbsp;As&nbsp;Integer)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>If&nbsp;KeyCode&nbsp;=&nbsp;Asc("A")&nbsp;And&nbsp;Shift&nbsp;=&nbsp;vbCtrlMask&nbsp;Then&nbsp;&nbsp;unload&nbsp;me&nbsp;'如果ctrl+A键被按下就退出<br/>&nbsp;&nbsp;&nbsp;&nbsp;End&nbsp;Sub&nbsp; <p></p><p><br/>例二:<br/>在Form中加入<br/>Private&nbsp;Declare&nbsp;Function&nbsp;GetAsyncKeyState&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;vkey&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Integer<br/>Private&nbsp;Function&nbsp;MyHotKey(vKeyCode)&nbsp;As&nbsp;Boolean<br/>MyHotKey&nbsp;=&nbsp;(GetAsyncKeyState(vKeyCode)&nbsp;&lt;&nbsp;0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;End&nbsp;Function<br/>'然后在循环中或Timer的Timer事件中检测:<br/>Private&nbsp;Sub&nbsp;Timer1_Timer()<br/>If&nbsp;MyHotKey(vbKeyA)&nbsp;And&nbsp;vbKeyControl&nbsp;Then&nbsp;&nbsp;&nbsp;'ctrl+A<br/>End&nbsp;&nbsp;'关闭<br/>End&nbsp;If<br/>'其中vbkeyA是键盘″A″的常数,其他键可按F1查得。<br/>End&nbsp;Sub</p>

暴米花 发表于 2006-12-12 11:48:00

<strong>控制鼠标的例子<br/><br/></strong><font color="#cc6600">一些控制鼠标的例子!&nbsp;</font><br/><font color="#cc6600">&nbsp;1.模拟鼠标击键过程&nbsp;</font><br/>'声明:<br/>Option&nbsp;Explicit<br/>&nbsp;&nbsp;&nbsp;&nbsp;Private&nbsp;Declare&nbsp;Sub&nbsp;mouse_event&nbsp;Lib&nbsp;"user32"&nbsp;&nbsp;(&nbsp;ByVal&nbsp;dwFlags&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;dx&nbsp;As&nbsp;Long,&nbsp;&nbsp;ByVal&nbsp;dy&nbsp;As&nbsp;Long,&nbsp;&nbsp;ByVal&nbsp;cButtons&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;dwExtraInfo&nbsp;As&nbsp;Long&nbsp;&nbsp;) <p></p><p>'对变量的定义<br/>Const&nbsp;MOUSEEVENTF_LEFTDOWN&nbsp;=&nbsp;&amp;H2<br/>Const&nbsp;MOUSEEVENTF_LEFTUP&nbsp;=&nbsp;&amp;H4<br/>Const&nbsp;MOUSEEVENTF_MIDDLEDOWN&nbsp;=&nbsp;&amp;H20<br/>Const&nbsp;MOUSEEVENTF_MIDDLEUP&nbsp;=&nbsp;&amp;H40<br/>Const&nbsp;MOUSEEVENTF_MOVE&nbsp;=&nbsp;&amp;H1<br/>Const&nbsp;MOUSEEVENTF_ABSOLUTE&nbsp;=&nbsp;&amp;H8000<br/>Const&nbsp;MOUSEEVENTF_RIGHTDOWN&nbsp;=&nbsp;&amp;H8<br/>Const&nbsp;MOUSEEVENTF_RIGHTUP&nbsp;=&nbsp;&amp;H10</p><p>&nbsp;&nbsp;'这里是&nbsp;鼠标左键按下&nbsp;和松开两个事件的组合即一次单击<br/>&nbsp;&nbsp;&nbsp;&nbsp;mouse_event&nbsp;MOUSEEVENTF_LEFTDOWN&nbsp;Or&nbsp;MOUSEEVENTF_LEFTUP,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0</p><p>&nbsp;&nbsp;&nbsp;&nbsp;'模拟鼠标右键单击事件<br/>&nbsp;&nbsp;&nbsp;&nbsp;mouse_event&nbsp;MOUSEEVENTF_RIGHTDOWN&nbsp;Or&nbsp;MOUSEEVENTF_RIGHTUP,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0</p><p>&nbsp;&nbsp;&nbsp;&nbsp;'两次连续的鼠标左键单击事件&nbsp;构成一次鼠标双击事件<br/>&nbsp;&nbsp;&nbsp;&nbsp;mouse_event&nbsp;MOUSEEVENTF_LEFTDOWN&nbsp;Or&nbsp;MOUSEEVENTF_LEFTUP,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0<br/>&nbsp;&nbsp;&nbsp;&nbsp;mouse_event&nbsp;MOUSEEVENTF_LEFTDOWN&nbsp;Or&nbsp;MOUSEEVENTF_LEFTUP,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0</p><p><font color="#cc6600">&nbsp;2.模拟鼠标显示.隐藏&nbsp;</font><br/>隐藏/显示鼠标.</p><p>Public&nbsp;Declare&nbsp;Function&nbsp;ShowCursor&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;bShow&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long</p><p>'forml中函数如下<br/>'隐藏鼠标(需要事件击活,比如窗体事件等)<br/>ShowCursor&nbsp;False<br/>'显示鼠标(需要事件击活,比如窗体事件等)<br/>ShowCursor&nbsp;True<br/><font color="#cc6600">&nbsp;3.定位鼠标,使之不能移动&nbsp;</font>&nbsp;<br/>定位鼠标。</p><p>Type&nbsp;rect<br/>&nbsp;&nbsp;&nbsp;&nbsp;sbleft&nbsp;As&nbsp;Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;sbtop&nbsp;As&nbsp;Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;sbright&nbsp;As&nbsp;Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;sbbottom&nbsp;As&nbsp;Long<br/>End&nbsp;Type</p><p>Public&nbsp;Declare&nbsp;Function&nbsp;ClipCursor&nbsp;Lib&nbsp;"user32"&nbsp;(lpRect&nbsp;As&nbsp;Any)&nbsp;As&nbsp;Long</p><p><br/>'鼠标定位<br/>Private&nbsp;Sub&nbsp;Form_Load()<br/>'定位鼠标<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;x&nbsp;As&nbsp;Long,&nbsp;y&nbsp;As&nbsp;Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;newrect&nbsp;As&nbsp;rect<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x&amp;&nbsp;=&nbsp;Screen.TwipsPerPixelX<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;y&amp;&nbsp;=&nbsp;Screen.TwipsPerPixelY<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;With&nbsp;newrect&nbsp;'鼠标只能在500,500-500,500这个范围内移动,如果四个数一样也可以说锁定鼠标了.如果加在记时器里的话就移动不了啦.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sbleft&nbsp;=&nbsp;500<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sbtop&nbsp;=&nbsp;500<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sbright&nbsp;=&nbsp;500<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sbbottom&nbsp;=&nbsp;500<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End&nbsp;With<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ClipCursor&nbsp;newrect<br/>如果鼠标被锁定,不能恢复怎么办?不用担心.看如下代码.<br/>'使鼠标恢复(设定一个事件.才好击活这个代码.)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;newrect&nbsp;As&nbsp;rect<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;With&nbsp;newrect&nbsp;&nbsp;'这样鼠标又可以在0,0-屏幕的最右角,屏幕的最右下脚移动了<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sbleft&nbsp;=&nbsp;0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sbtop&nbsp;=&nbsp;0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sbright&nbsp;=&nbsp;Screen.Width&nbsp;/&nbsp;Screen.TwipsPerPixelX<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.sbbottom&nbsp;=&nbsp;Screen.Height&nbsp;/&nbsp;Screen.TwipsPerPixelY<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End&nbsp;With<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ClipCursor&nbsp;newrect<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End&nbsp;Sub<br/><font color="#cc6600">&nbsp;&nbsp;4.移动鼠标到某某点</font><br/>移动鼠标.<br/>Public&nbsp;Declare&nbsp;Function&nbsp;SetCursorPos&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;x&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;y&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>窗口函数如下:<br/>SetCursorPos&nbsp;0,&nbsp;0&nbsp;'鼠标移动到0,0点<br/><font color="#cc6600">&nbsp;5.鼠标坐标</font><br/>鼠标坐标.<br/>Type&nbsp;POINTAPI<br/>&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;As&nbsp;Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;y&nbsp;As&nbsp;Long<br/>End&nbsp;Type<br/>Public&nbsp;Declare&nbsp;Function&nbsp;GetCursorPos&nbsp;Lib&nbsp;"user32"&nbsp;(lpPoint&nbsp;As&nbsp;POINTAPI)&nbsp;As&nbsp;Long<br/>'鼠标坐标:<br/>在窗口中设立一记时器。一显示框。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;z&nbsp;As&nbsp;POINTAPI&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetCursorPos&nbsp;z<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Label1.Caption&nbsp;=&nbsp;"x:&nbsp;"&nbsp;&amp;&nbsp;z.x&nbsp;&amp;&nbsp;"&nbsp;y:&nbsp;"&nbsp;&amp;&nbsp;z.y&nbsp;'设定一个显示点label1.<br/><font color="#cc6600">&nbsp;6.鼠标键数</font><br/>'鼠标键数.</p><p>Public&nbsp;Declare&nbsp;Function&nbsp;GetSystemMetrics&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;nIndex&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long</p><p>'鼠标键数<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;mousebtn&nbsp;As&nbsp;Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mousebtn&nbsp;=&nbsp;GetSystemMetrics(43)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Label1.Caption&nbsp;=&nbsp;"你的鼠标是&nbsp;"&nbsp;&amp;&nbsp;mousebtn&nbsp;&amp;&nbsp;"&nbsp;键鼠标!"&nbsp;'设定一个显示点label1.</p><p>以上也可以使用其他方式模拟.<br/></p>

暴米花 发表于 2006-12-12 11:48:00

<font color="#cc6600">窗口类函数&nbsp;</font>
        <p></p><p><br/>SetWindowPos函数:使窗口停留在屏幕最顶层。<br/>声明:<br/>Private&nbsp;Declare&nbsp;Function&nbsp;SetWindowPos&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;_<br/>ByVal&nbsp;hWndinsertAfter&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;x&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;y&nbsp;As&nbsp;Long,&nbsp;_<br/>ByVal&nbsp;cx&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;cy&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;wFlags&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>调用如:<br/>Private&nbsp;Sub&nbsp;Form_Load()<br/>SetWindowPos&nbsp;hwnd,&nbsp;HWND_TOPMOST,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;&amp;H2&nbsp;+&nbsp;&amp;H1<br/>End&nbsp;Sub&nbsp;窗口form1将保留在屏幕表面。<br/>该函数功能是为窗口指定1个新的位置和状态。参数:<br/>hwnd:欲定位的窗口。<br/>hwndinsertAfter:指定窗口的位置。&nbsp;可能选用下述值之一:&nbsp;<br/>HWND_BOTTOM&nbsp;将窗口置于窗口列表底部&nbsp;<br/>HWND_TOP&nbsp;将窗口置于Z序列的顶部;Z序列代表在分级结构中,窗口针对一个给定级别的窗口显示的顺序&nbsp;<br/>HWND_TOPMOST(值-1)&nbsp;将窗口置于列表顶部,并位于任何最顶部窗口的前面&nbsp;<br/>HWND_NOTOPMOST(值-2)&nbsp;将窗口置于列表顶部,并位于任何最顶部窗口的后面&nbsp;<br/>x:&nbsp;窗口新的x坐标。如hwnd是一个子窗口,则x用父窗口的客户区坐标表示&nbsp;<br/>y:&nbsp;窗口新的y坐标。如hwnd是一个子窗口,则y用父窗口的客户区坐标表示&nbsp;<br/>cx:指定新的窗口宽度&nbsp;<br/>cy:指定新的窗口高度&nbsp;<br/>wFlags:包含了游标的一个整数,可能为下述值或其组合。&nbsp;<br/>SWP_DRAWFRAME&nbsp;围绕窗口画一个框&nbsp;<br/>SWP_HIDEWINDOW&nbsp;隐藏窗口&nbsp;<br/>SWP_NOACTIVATE&nbsp;不激活窗口&nbsp;<br/>SWP_NOMOVE&nbsp;保持当前位置(x和y设定将被忽略)&nbsp;<br/>SWP_NOREDRAW&nbsp;窗口不自动重画&nbsp;<br/>SWP_NOSIZE&nbsp;保持当前大小(cx和cy会被忽略)&nbsp;<br/>SWP_NOZORDER&nbsp;保持窗口在列表的当前位置(hWndInsertAfter将被忽略)&nbsp;<br/>SWP_SHOWWINDOW&nbsp;显示窗口&nbsp;<br/>SWP_FRAMECHANGED&nbsp;强迫一条WM_NCCALCSIZE消息进入窗口,即使窗口的大小没有改变&nbsp;<br/>======<br/>移动无标题栏的窗口:在标准模块中声明<br/>Declare&nbsp;Function&nbsp;ReleaseCapture&nbsp;Lib&nbsp;"user32"&nbsp;()&nbsp;As&nbsp;Long<br/>ReleaseCapture函数:为当前程序释放鼠标捕获。<br/>Declare&nbsp;Function&nbsp;SendMessage&nbsp;Lib&nbsp;"user32"&nbsp;_<br/>Alias&nbsp;"SendMessageA"&nbsp;(&nbsp;_<br/>ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;wMsg&nbsp;As&nbsp;Long,&nbsp;_<br/>ByVal&nbsp;wParam&nbsp;As&nbsp;Long,&nbsp;lParam&nbsp;As&nbsp;Any)&nbsp;As&nbsp;Long<br/>Public&nbsp;Const&nbsp;HTCAPTION&nbsp;=&nbsp;2<br/>Public&nbsp;Const&nbsp;WM_NCLBUTTONDOWN&nbsp;=&nbsp;&amp;HA1&nbsp;此消息指在窗口的非客户区域内按下左键<br/>在FORM_mousedown事件中写:<br/>Private&nbsp;Sub&nbsp;Form_MouseDown(Button&nbsp;As&nbsp;Integer,&nbsp;Shift&nbsp;As&nbsp;Integer,&nbsp;X&nbsp;As&nbsp;Single,&nbsp;Y&nbsp;As&nbsp;Single)<br/>ReleaseCapture&nbsp;(此句为释放鼠标本来在Form客户区的捕获)<br/>SendMessage&nbsp;hwnd,&nbsp;WM_NCLBUTTONDOWN,&nbsp;HTCAPTION,&nbsp;0&amp;<br/>End&nbsp;Sub<br/>====<br/>创建椭圆(不规则)窗口:SetWindowRgn函数结合CreateEllipticRgn椭圆函数<br/>SetWindowRgn函数用来创建不规则窗口,如椭圆(结合CreateEllipticRgn),多边形(结合CreatePolygonRgn),矩形(结合CreateRectRgn),圆角矩形(结合CreateRoundRectRgn)等。&nbsp;<br/>声明:<br/>Private&nbsp;Declare&nbsp;Function&nbsp;CreateEllipticRgn&nbsp;Lib&nbsp;"gdi32"&nbsp;(ByVal&nbsp;X1&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;Y1&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;X2&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;Y2&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;SetWindowRgn&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;hWnd&nbsp;As&nbsp;Long,&nbsp;_<br/>ByVal&nbsp;hRgn&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;bRedraw&nbsp;As&nbsp;Boolean)&nbsp;As&nbsp;Long<br/>调用如:<br/>Private&nbsp;Sub&nbsp;Form_Load()<br/>SetWindowRgn&nbsp;hWnd,&nbsp;CreateEllipticRgn(0,&nbsp;0,&nbsp;300,&nbsp;200),&nbsp;True<br/>End&nbsp;Sub<br/>SetWindowRgn函数用于创建不规则窗口,可创建任何几何形状的窗口,只要用Create…Rgn函数返回值传入各种形状区域句柄,参数:<br/>参数&nbsp;类型及说明&nbsp;<br/>hWnd:将设置其区域的窗口的句柄。&nbsp;<br/>hRgn:设置好的区域的句柄,一旦设置了该区域,就不能使用或修改该区域句柄,也不要删除它&nbsp;<br/>bRedraw:是否立即重画窗口,若为TRUE,则立即重画窗口&nbsp;<br/>注:为区域指定的所有坐标都以窗口坐标(和客户坐标不完全相同)表示,它们以整个窗口(包括标题栏和边框,而客户坐标是指不包括标题栏的窗口内部有效区域)的左上角为起点<br/>椭圆CreateEllipticRgn函数:创建一个椭圆,该椭圆以X1,Y1和X2,Y2坐标点确定的矩形内切。参数:<br/>X1,Y1:内切矩形左上角X,Y坐标&nbsp;<br/>X2,Y2:内切矩形右下角X,Y坐标&nbsp;<br/>====<br/>得到屏幕有效区大小(除去任务条):SystemParametersInfoA<br/>声明:<br/>Private&nbsp;Type&nbsp;RECT&nbsp;<br/>Left&nbsp;As&nbsp;Long<br/>top&nbsp;As&nbsp;Long<br/>Right&nbsp;As&nbsp;Long<br/>Botton&nbsp;As&nbsp;Long<br/>End&nbsp;Type<br/>Private&nbsp;Declare&nbsp;Function&nbsp;SystemParametersInfoA&nbsp;Lib&nbsp;"user32"&nbsp;_<br/>(ByVal&nbsp;uAction&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;uParam&nbsp;As&nbsp;Long,&nbsp;ByRef&nbsp;lpvparam&nbsp;_<br/>As&nbsp;Any,&nbsp;ByVal&nbsp;fuWinIni&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>调用如:将窗体移到屏幕有效区中央。<br/>Private&nbsp;Sub&nbsp;Command2_Click()<br/>Dim&nbsp;ScreenWidth&amp;<br/>Dim&nbsp;ScreenHeight&amp;<br/>Dim&nbsp;ScreenLeft&amp;<br/>Dim&nbsp;ScreenTop&amp;<br/>Dim&nbsp;DesktopArea&nbsp;As&nbsp;RECT<br/>Const&nbsp;SPI_GETWORKAREA&nbsp;=&nbsp;48&nbsp;<br/>Call&nbsp;SystemParametersInfoA(SPI_GETWORKAREA,&nbsp;0,&nbsp;DesktopArea,&nbsp;0)<br/>ScreenHeight&nbsp;=&nbsp;(DesktopArea.Botton&nbsp;-&nbsp;DesktopArea.top)&nbsp;*&nbsp;Screen.TwipsPerPixelY<br/>ScreenWidth&nbsp;=&nbsp;(DesktopArea.Right&nbsp;-&nbsp;DesktopArea.Left)&nbsp;*&nbsp;Screen.TwipsPerPixelX<br/>ScreenLeft&nbsp;=&nbsp;DesktopArea.Left&nbsp;*&nbsp;Screen.TwipsPerPixelX<br/>ScreenTop&nbsp;=&nbsp;DesktopArea.top&nbsp;*&nbsp;Screen.TwipsPerPixelY<br/>Form1.Move&nbsp;(ScreenWidth&nbsp;-&nbsp;Form1.Width)&nbsp;/&nbsp;2&nbsp;+&nbsp;ScreenLeft,&nbsp;(ScreenHeight&nbsp;-&nbsp;Form1.Height)&nbsp;/&nbsp;2&nbsp;+&nbsp;ScreenTop<br/>End&nbsp;Sub<br/>SystemParametersInfoA函数可用来获取和设置数量众多的windows系统参数。<br/>参数请查看资料。<br/>====<br/>获得窗口在屏幕上的范围:GetWindowRect函数<br/>包括窗口的边框,标题栏,滚动条及菜单,客户区等在内,即整个窗口在屏幕上所占的范围.声明:<br/>Declare&nbsp;Function&nbsp;GetWindowRect&nbsp;Lib&nbsp;"user32"(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;lpRect&nbsp;As&nbsp;RECT)&nbsp;As&nbsp;Long<br/>第一个参数是窗口句柄,第二个参数装载窗口范围的坐标值,为一个结构类型,声明如下:<br/>Public&nbsp;Type&nbsp;RECT<br/>Left&nbsp;As&nbsp;Long<br/>Top&nbsp;As&nbsp;Long<br/>Right&nbsp;As&nbsp;Long<br/>Bottom&nbsp;As&nbsp;Long<br/>End&nbsp;Type<br/>该参数返回窗口在屏幕中的范围值,单位为象素。调用如:<br/>Private&nbsp;Sub&nbsp;Command1_Click()<br/>GetWindowRect&nbsp;Command1.hwnd,&nbsp;lxx<br/>Print&nbsp;lxx.Left,&nbsp;lxx.Top,&nbsp;lxx.Right,&nbsp;lxx.Bottom&nbsp;<br/>End&nbsp;Sub<br/>===========================================<br/>改变指定窗口的位置和大小:MoveWindow函数<br/>相当于VB内置的Move方法,但作为API,功能当然更强大,它可对任何非本进程的窗口进行改变,声明:<br/>Declare&nbsp;Function&nbsp;MoveWindow&nbsp;Lib&nbsp;"user32"(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;x&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;y&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;nWidth&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;nHeight&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;bRepaint&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>第一个参数为要移动的窗口句柄,第二,三,四,五个参数为窗口移动后的新横坐标,新纵坐标,新宽度,新高度,第六个参数为是否立即对窗口进行重画,用True或False。调用如:<br/>MoveWindow&nbsp;Command1.hwnd,&nbsp;0,&nbsp;0,&nbsp;100,&nbsp;100,&nbsp;True<br/>因为改变的是对象在父窗口中的位置,所以Command1按纽被移到窗体Form1的客户区左上角去了。&nbsp;<br/>=====<br/>判断屏幕上1指定点的客户区坐标:ScreenToClient函数&nbsp;<br/>判断屏幕上某点相对于指定窗口内的坐标。声明:<br/>Private&nbsp;Type&nbsp;POINTAPI<br/>x&nbsp;As&nbsp;Long<br/>y&nbsp;As&nbsp;Long<br/>End&nbsp;Type<br/>Private&nbsp;Declare&nbsp;Function&nbsp;ScreenToClient&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;lpPoint&nbsp;As&nbsp;POINTAPI)&nbsp;As&nbsp;Long<br/>该函数用以测量点lpPoint在句柄为hwnd的窗口内的坐标(如超越此窗口则为负数)。调用如:<br/>Private&nbsp;Sub&nbsp;Command1_Click()<br/>Dim&nbsp;lxn&nbsp;As&nbsp;POINTAPI<br/>lxn.x&nbsp;=&nbsp;100:&nbsp;lxn.y&nbsp;=&nbsp;100<br/>Call&nbsp;ScreenToClient(Form1.hwnd,&nbsp;lxn)<br/>Print&nbsp;lxn.x,&nbsp;lxn.y<br/>End&nbsp;Sub<br/>上例在调用前的lxn参数100,100是屏幕坐标,调用函数后lxn的值是"屏幕坐标为(100,100)的点在form1中的客户坐标是多少。如返回lxn.x=41,lxn.y=38,单位仍为象素,不会变为form1内部的缇。<br/>===<br/>获得窗口内以客户坐标表示的1个点的屏幕坐标&nbsp;:&nbsp;ClientToScreen函数<br/>该函数与上面那个正好相反。这里是已知客户坐标求屏幕坐标。注:客户坐标单位须先转为象素。<br/>声明:<br/>Declare&nbsp;Function&nbsp;ClientToScreen&nbsp;Lib&nbsp;"user32"(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;lpPoint&nbsp;As&nbsp;POINTAPI)&nbsp;As&nbsp;Long<br/>参数hwnd:点所在的客户区窗口的句柄。<br/>参数lpPoint:传入点的客户区坐标(单位要为象素),并返回点的屏幕坐标(象素)。<br/>调用如:&nbsp;<br/>Dim&nbsp;m&nbsp;As&nbsp;POINTAPI<br/>m.X&nbsp;=&nbsp;50:&nbsp;m.Y&nbsp;=&nbsp;70<br/>a&nbsp;=&nbsp;ClientToScreen(Form1.hwnd,&nbsp;m)<br/>Print&nbsp;m.X,&nbsp;m.Y<br/>该函数应用的是参数lpPoint返回值。&nbsp;<br/>======<br/>获得屏幕上某指定点所在的窗口的句柄&nbsp;:&nbsp;WindowFromPoint函数&nbsp;<br/>声明:<br/>Private&nbsp;Declare&nbsp;Function&nbsp;WindowFromPoint&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;xPoint&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;yPoint&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>参数xPoint,yPoint是某点的"屏幕坐标"。函数返回值为包含该点的窗口句柄。<br/>调用如:<br/>Private&nbsp;Sub&nbsp;Command2_Click()<br/>Dim&nbsp;hwnd&nbsp;As&nbsp;Long<br/>hwnd&nbsp;=&nbsp;WindowFromPoint(1,&nbsp;1)<br/>Print&nbsp;hwnd<br/>End&nbsp;Sub<br/>上例表示屏幕上点(1,1)处在句柄为hwnd的窗口内。<br/>此函数返回的句柄不包含隐藏、屏蔽、透明窗口的。如果要指出屏幕上某点所属的所有窗口,就请用ChildWindowFromPoint函数。<br/>===========&nbsp;获取屏幕上某个窗口内某点的颜色值:&nbsp;GetPixel函数<br/>该函数在指定设备场景中取得1个象素的颜色RGB值。<br/>声明:<br/>Public&nbsp;Declare&nbsp;Function&nbsp;GetPixel&nbsp;Lib&nbsp;"gdi32"&nbsp;Alias&nbsp;"GetPixel"&nbsp;(ByVal&nbsp;hdc&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;x&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;y&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>参数:<br/>hDC--指定一个设备场景(即显示设备描述表)的句柄。<br/>x,y--某点在该设备场景中的(x,y)坐标。以该设备场景的坐标系统来度量。<br/>调用如:<br/>……<br/>hDC=GetDC(hwnd)<br/>lxn=GetPixel(hDC,50,50)&nbsp;<br/>Picture1.BackColor=lxn<br/>注:指定的点不能位于设备场景的区域外。如上例(50,50)在hDC所属窗口区域内<br/>====<br/>EnableWindow函数:让窗口拒绝接受鼠标和键盘事件<br/>使用此函数,可以让1个窗口不响应任何鼠标键盘操作。如果是VB内部的窗体或控件,则相当于它的Enabled属性。<br/>声明:<br/>Private&nbsp;Declare&nbsp;Function&nbsp;EnableWindow&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;fEnable&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>调用如:&nbsp;Call&nbsp;EnableWindow(Form1.hwnd,&nbsp;0)为拒绝接受鼠标和键盘事件,<br/>调用如:&nbsp;Call&nbsp;EnableWindow(Form1.hwnd,&nbsp;1)为允许接受键盘和鼠标事件。<br/>参数:hwnd不用说,就是一个窗口句柄,fEnable参数:窗口是否响应操作。为零禁止操作窗口,非零允许操作窗口。<br/>=====<br/>ShowWindow函数:显示或隐藏指定句柄的窗口<br/>将1个隐藏的窗口显示出来,有意思,相当于VB自身内部控件的visible属性。而且超越于此,它还能指定显示时是否最大化,最小化等,声明如下:<br/>Public&nbsp;Declare&nbsp;Function&nbsp;ShowWindow&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;nCmdShow&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long&nbsp;<br/>调用如:<br/>Const&nbsp;SW_HIDE&nbsp;=&nbsp;0&nbsp;参数nCmdShow之一,隐藏窗口<br/>Const&nbsp;SW_SHOW&nbsp;=&nbsp;5&nbsp;显示窗口&nbsp;<br/>i&nbsp;=&nbsp;ShowWindow(form1.hwnd,&nbsp;SW_HIDE)<br/>参数:<br/>hwnd:&nbsp;Long,窗口句柄,要向这个窗口应用由nCmdShow指定的命令&nbsp;<br/>nCmdShow:&nbsp;Long,为窗口指定显示或隐藏的一个命令。请用下述任何一个常数&nbsp;<br/>SW_HIDE&nbsp;隐藏窗口,活动状态给令一个窗口&nbsp;<br/>SW_MINIMIZE&nbsp;最小化窗口,活动状态给令一个窗口&nbsp;<br/>SW_RESTORE&nbsp;用原来的大小和位置显示一个窗口,同时令其进入活动状态&nbsp;<br/>SW_SHOW=5&nbsp;用当前的大小和位置显示一个窗口,同时令其进入活动状态&nbsp;<br/>SW_SHOWMAXIMIZED=3&nbsp;最大化窗口,并将其激活&nbsp;<br/>SW_SHOWMINIMIZED=2&nbsp;最小化窗口,并将其激活&nbsp;<br/>SW_SHOWDEFAULT=10&nbsp;按窗口本来的方式显示,并激活。<br/>SW_SHOWMINNOACTIVE&nbsp;最小化一个窗口,同时不改变活动窗口&nbsp;<br/>SW_SHOWNA&nbsp;用当前的大小和位置显示一个窗口,不改变活动窗口&nbsp;<br/>SW_SHOWNOACTIVATE&nbsp;用最近的大小和位置显示一个窗口,同时不改变活动窗口&nbsp;<br/>SW_SHOWNORMAL&nbsp;与SW_RESTORE相同&nbsp;<br/>注:各常数的值请查阅API浏览器中的constants(常数列表)。<br/>======<br/>关闭指定句柄的窗口:SendMessageA的WM_CLOSE消息&nbsp;<br/>SendMessageA的声明在前面有,消息WM_CLOSE的值为&amp;H10,后两个参数为空,用0&amp;。函数返回值若为0表示程序处理了此消息。调用如下:<br/>Private&nbsp;Declare&nbsp;Function&nbsp;SendMessage&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"SendMessageA"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;wMsg&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;wParam&nbsp;As&nbsp;Long,&nbsp;lParam&nbsp;As&nbsp;Any)&nbsp;As&nbsp;Long<br/>Const&nbsp;WM_CLOSE&nbsp;=&nbsp;&amp;H10<br/>Private&nbsp;Sub&nbsp;Command1_Click()<br/>SendMessage&nbsp;Form1.hwnd,&nbsp;WM_CLOSE,&nbsp;0&amp;,&nbsp;0&amp;<br/>End&nbsp;Sub<br/>还有一个强制从内存中清除窗口的函数:DestroyWindow函数<br/>其功能是直接清除掉内存中的1个窗口,返回非0表示成功,返回0表示失败。声明:<br/>Public&nbsp;Declare&nbsp;Function&nbsp;DestroyWindow&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long)<br/>很简单,参数只是指定1个窗口句柄。调用如:DestroyWindow&nbsp;Form1.hwnd。<br/>=====<br/>寻找窗口列表中第一个符合条件的父窗口:&nbsp;FindWindowA函数&nbsp;<br/>Declare&nbsp;Function&nbsp;FindWindow&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"FindWindowA"&nbsp;(ByVal&nbsp;lpClassName&nbsp;As&nbsp;String,&nbsp;ByVal&nbsp;lpWindowName&nbsp;As&nbsp;String)&nbsp;As&nbsp;Long<br/>函数返回找到的窗口的句柄。比如要查找标题为"未命名-记事本"的窗口句柄:<br/>hWndTmp&nbsp;=&nbsp;FindWindowA(vbNullString,"未命名-记事本")&nbsp;二个参数均为字符串,如果某个为空,则用vbNullString或0&amp;补上。<br/>参数:<br/>lpClassName:某窗口类名,或设为零或vbNullString,表示接收任何类&nbsp;<br/>lpWindowName:某窗口标题,或设为零或vbNullString,表示接收任何窗口标题&nbsp;。<br/>该函数常用来查找ThunderRTMain窗口类的隐藏窗口的句柄。例如:<br/>Dim&nbsp;hw&amp;,&nbsp;cnt&amp;<br/>Dim&nbsp;rttitle&nbsp;As&nbsp;String&nbsp;*&nbsp;256<br/>hw&amp;&nbsp;=&nbsp;FindWindowA("ThunderRT5Main",&nbsp;vbNullString)&nbsp;<br/>cnt&nbsp;=&nbsp;GetWindowText(hw&amp;,&nbsp;rttitle,&nbsp;255)<br/>MsgBox&nbsp;Left$(rttitle,&nbsp;cnt),&nbsp;0,&nbsp;"RTMain&nbsp;title"&nbsp;<br/>=====<br/>根据1个窗口句柄返回另1个相关窗口句柄&nbsp;:GetWindow函数<br/>传入一个源窗口句柄,返回另1个与之有关的窗口句柄,如源窗口的下1个兄弟窗口,第1个子窗口等。声明:<br/>Declare&nbsp;Function&nbsp;GetWindow&nbsp;Lib&nbsp;"user32"(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;wCmd&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>调用如:<br/>Const&nbsp;GW_HWNDNEXT&nbsp;=&nbsp;2&nbsp;<br/>hWndlxn&nbsp;=&nbsp;GetWindow(hWndTmp,&nbsp;GW_HWNDNEXT)<br/>参数:hwnd:源窗口句柄。&nbsp;<br/>wCmd参数:指定结果窗口与源窗口的关系,它们建立在下述常数基础上:&nbsp;<br/>GW_CHILD&nbsp;寻找源窗口的第一个子窗口&nbsp;<br/>GW_HWNDFIRST&nbsp;为一个源子窗口寻找第一个兄弟(同级)窗口,或寻找第一个顶级窗口&nbsp;<br/>GW_HWNDLAST&nbsp;为一个源子窗口寻找最后一个兄弟(同级)窗口,或寻找最后一个顶级窗口&nbsp;<br/>GW_HWNDNEXT&nbsp;为源窗口寻找下一个兄弟窗口&nbsp;<br/>GW_HWNDPREV&nbsp;为源窗口寻找前一个兄弟窗口&nbsp;<br/>GW_OWNER&nbsp;寻找窗口的所有者&nbsp;<br/>注解&nbsp;<br/>兄弟或同级是指在整个分级结构中位于同一级别的窗口。如某个窗口有五个子窗口,那五个窗口就是兄弟窗口。尽管GetWindow可用于枚举窗口,但倘若要在枚举过程中重新定位、创建和清除窗口,那么EnumWindows和EnumChildWindows更为可靠。<br/>=====<br/>GetWindowLongA函数:获得指定窗口某方面的结构信息(返回长整数)。<br/>问题:什么叫"窗口的结构数据信息"?就是1个窗口的诸方面情况吧,象人有姓名性别年龄等一样,窗口有"扩展样式(包含标题栏,如在Form1中表现为BorderStyle属性,有标题栏缩小、无标题栏等的组合值)","样式(包含滚动条、系统菜单、边框等可设置)","父窗口","子窗口","窗口函数"等诸多方面,见下面nIndex参数值。这些方面的内容(每1方面只能有1个当前值)就构成了窗口的结构信息。<br/>该函数从附加窗口内存中返回1个长整数值。<br/>声明:<br/>Public&nbsp;Declare&nbsp;Function&nbsp;GetWindowLong&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"GetWindowLongA"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;nIndex&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>此函数用来获取指定窗口的某方面"结构数据"信息。&nbsp;函数返回值由参数nIndex来决定要返回哪个方面的当前值。若出错则返回0。<br/>调用如:Const&nbsp;GWL_STYLE&nbsp;=&nbsp;-16<br/>Private&nbsp;Sub&nbsp;Command1_Click()<br/>X&nbsp;=&nbsp;GetWindowLongA(Form1.hwnd,&nbsp;GWL_STYLE)<br/>Print&nbsp;X<br/>End&nbsp;Sub<br/>参数:<br/>hwnd:&nbsp;Long,欲获取信息的窗口的句柄&nbsp;<br/>nIndex:&nbsp;Long,欲取回此窗口哪方面的信息,可以是下述任何一个常数:&nbsp;<br/>GWL_EXSTYLE&nbsp;扩展窗口样式&nbsp;<br/>(可能包含有:WS_EX_TOOLWINDOW=&amp;H80标题栏缩小可变大小,相当于BorderStyle=5;&nbsp;WS_EX_TRANSPARENT=&amp;H20&amp;隐藏绘图区,但显示其上的子控件。有意思。等,别的我也不太清楚,好象要去查MSDN才可查到)&nbsp;<br/>GWL_STYLE&nbsp;窗口样式&nbsp;<br/>(可能值有:WS_VSCROLL=?垂直滚动条,WS_HSCROLL=?水平滚动条,<br/>WS_MAXIMIZEBOX=?标题栏右边最大化纽,WS_MINIMIZEBOX=?最小化纽等等)<br/>GWL_WNDPROC&nbsp;该窗口的窗口函数的地址&nbsp;<br/>GWL_HINSTANCE&nbsp;拥有窗口的实例的句柄&nbsp;<br/>GWL_HWNDPARENT&nbsp;该窗口之父的句柄。不要用SetWindowWord来改变这个值&nbsp;<br/>GWL_ID&nbsp;对话框中一个子窗口的标识符&nbsp;<br/>GWL_USERDATA&nbsp;含义由应用程序规定&nbsp;<br/>DWL_DLGPROC&nbsp;这个窗口的对话框函数地址&nbsp;<br/>DWL_MSGRESULT&nbsp;在对话框函数中处理的一条消息返回的值&nbsp;<br/>DWL_USER&nbsp;含义由应用程序规定&nbsp;<br/>-----<br/>SetWindowLongA函数:为窗口设置窗口结构信息<br/>常用此函数来动态地设置窗口的风格(如样式,滚动条等等)。即不在属性窗口中设置。而在API中设置。&nbsp;<br/>声明:<br/>Public&nbsp;Declare&nbsp;Function&nbsp;SetWindowLong&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"SetWindowLongA"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;nIndex&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;dwNewLong&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>调用如:<br/>Public&nbsp;Const&nbsp;WS_EX_TOOLWINDOW&nbsp;=&nbsp;&amp;H80<br/>lStyle&nbsp;=&nbsp;WS_EX_TOOLWINDOW<br/>lRet&nbsp;=&nbsp;SetWindowLongA(Me.hwnd,&nbsp;GWL_EXSTYLE,&nbsp;GetWindowLongA(Me.hwnd,&nbsp;GWL_EXSTYLE)&nbsp;Or&nbsp;lStyle)&nbsp;注:这里有1个Or"或"操作。为何要用OR呢?这是因为一个窗口的GWL_EXSTYLE包含了多项设置值的和(如同时可能有滚动条,标题栏等值的组合,如为262400),用or就可只改动其部分值,而保留其他方面原设置不变。<br/>参数:<br/>hwnd&nbsp;Long,欲设置信息的窗口的句柄&nbsp;<br/>nIndex&nbsp;Long,请参考GetWindowLong函数的nIndex参数的说明&nbsp;<br/>dwNewLong&nbsp;Long,由nIndex指定的窗口信息的新值&nbsp;<br/>-------<br/>GetWindowWord函数:获得指定窗口的结构信息(返回字值)&nbsp;<br/>该函数从附加窗口内存中返回字值。与GetWindowLong相似。&nbsp;<br/>声明:&nbsp;<br/>Declare&nbsp;Function&nbsp;GetWindowWord&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"GetWindowWord"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;nIndex&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Integer<br/>调用如:<br/>Const&nbsp;GWL_HWNDPARENT&nbsp;=&nbsp;-8<br/>parent&nbsp;=&nbsp;GetWindowWord(Form1.hwnd,&nbsp;GWL_HWNDPARENT)&nbsp;<br/>这里调用后parent返回Form1的上一级父窗口的句柄。再例如command1在form1中,&nbsp;x=GetWindowWord(command1.hwnd,GWL_HWNDPARENT)返回的x就等于form1.hwnd.<br/>参数见GetWindowLong.<br/>======<br/>获得指定窗口所属的窗口类名称:GetClassNameA函数<br/>声明:<br/>Declare&nbsp;Function&nbsp;GetClassName&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"GetClassNameA"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;lpClassName&nbsp;As&nbsp;String,&nbsp;ByVal&nbsp;nMaxCount&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>调用如--求Form1所属的窗口类的名称&nbsp;:<br/>pclass&nbsp;=&nbsp;Space(31)&nbsp;<br/>nlen&nbsp;=&nbsp;GetClassNameA(form1.hwnd,&nbsp;pclass,&nbsp;32)<br/>pclass&nbsp;=&nbsp;Left(pclass,&nbsp;nlen)<br/>第1个参数为某窗口句柄。第2个参数为字符串缓冲区,第3个参数为缓冲区长度。<br/>参数lpClassName返回值为窗口类名称字符串,如上例为ThunderFormDC类。<br/>函数返回值为类名字符串长度。如上面nlen为13。<br/>====<br/>创建不规则窗口之"圆角矩形":SetWindowRgn结合CreateRoundRectRgn函数<br/>SetWindowRgn函数用于创建各种几何形状的窗口,声明前面已有,为:<br/>Public&nbsp;Declare&nbsp;Function&nbsp;SetWindowRgn&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"SetWindowRgn"&nbsp;(ByVal&nbsp;hWnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;hRgn&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;bRedraw&nbsp;As&nbsp;Boolean)&nbsp;As&nbsp;Long<br/>第1个参数为窗口句柄,第2个参数为几何形状区域句柄,第3个参数为是否立即重画。&nbsp;<br/>函数CreateRoundRectRgn为创建圆角矩形,函数返回创建的圆角区域句柄。声明:<br/>Public&nbsp;Declare&nbsp;Function&nbsp;CreateRoundRectRgn&nbsp;Lib&nbsp;"gdi32"&nbsp;(ByVal&nbsp;X1&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;Y1&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;X2&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;Y2&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;X3&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;Y3&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>参数就是三个(X,Y)值,X1,Y1为左上角坐标,因为是用窗口自身坐标系统来度量,所以左上角坐标一般为0,0(注:FORM窗体为scaleleft,scaletop),X2,Y2为右下角坐标(注意不一定是直接的width或scalewidth,要用scaleleft+scalewidth才是"右下角"横坐标):如果是控件,就是其width,height的值,而如果是窗体,要加上其scaleleft,scaletop<br/>得到右下角坐标值。X3,Y3表示圆角的大小。X3的取值范围是0(无圆角)到矩形宽(width或scalewidth,全圆),Y3的取值范围是0(无圆角)到矩形高(height或scaleheight,全圆),常乘以一个0至1的单精度数来表示。例如:<br/>x&nbsp;=&nbsp;SetWindowRgn(form1.hwnd,&nbsp;CreateRoundRectRgn(form1.ScaleLeft,&nbsp;form1.ScaleTop,&nbsp;form1.ScaleWidth&nbsp;+&nbsp;form1.ScaleLeft,&nbsp;form1.ScaleHeight&nbsp;+&nbsp;form1.ScaleTop,&nbsp;form1.ScaleWidth&nbsp;*&nbsp;0.6,&nbsp;form1.ScaleHeight&nbsp;*&nbsp;0.6),&nbsp;True)<br/>最后说明一下,还有一个API函数可直接画圆角矩形,就是RoundRect函数。声明:<br/>Declare&nbsp;Function&nbsp;RoundRect&nbsp;Lib&nbsp;"gdi32"&nbsp;(ByVal&nbsp;hdc&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;X1&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;Y1&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;X2&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;Y2&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;X3&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;Y3&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>其中参数hDC是窗口的设备场景句柄。三个(X,Y)和CreateRoundRectRgn的是一样的,分别为左上角,右下角坐标和圆角大小。<br/>======<br/>获取本程序活动窗口的句柄:GetActiveWindow函数<br/>声明:<br/>Declare&nbsp;Function&nbsp;GetActiveWindow&nbsp;Lib&nbsp;"user32"()&nbsp;As&nbsp;Long<br/>很简单,函数返回值为当前本程序活动窗口句柄。调用如:x=GetActiveWindow,这个函数不如GetForegroundWindow函数,建议用下面的:<br/>----<br/>获取屏幕上当前活动窗口的句柄:GetForegroundWindow函数<br/>这个函数功能更强大,能获取前台应用程序的活动窗口句柄。声明:<br/>Declare&nbsp;Function&nbsp;GetForegroundWindow&nbsp;Lib&nbsp;"user32"&nbsp;()&nbsp;As&nbsp;Long<br/>函数返回值为当前屏幕上活动窗口的句柄,如:x=GetForegroundWindow。<br/>-----<br/>判断一个窗口是否是活动窗口:IsWindowEnabled函数<br/>声明:<br/>Declare&nbsp;Function&nbsp;IsWindowEnabled&nbsp;Lib&nbsp;"user32"(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long&nbsp;<br/>参数hwnd是待检测窗口句柄。<br/>调用如:x=IsWindowEnabled(Form1.hwnd),函数返回值若非0表示为活动窗口,返回0表示为失效窗口。<br/>----<br/>禁止任务条--任务条所属窗口类为"Shell_traywnd",用FindWindowA函数去查,如下:&nbsp;TaskBarhWnd&nbsp;=&nbsp;FindWindowA("Shell_traywnd",&nbsp;""),然后用EnableWindow函数:&nbsp;lxn&nbsp;=&nbsp;EnableWindow(TaskBarhWnd,0)就可以了。</p>

暴米花 发表于 2006-12-12 11:49:00

<strong>取得窗口的句柄.类.名称等<br/><br/></strong><font color="#cc6600">&nbsp;</font><p></p><p>建立三个label1/label2/lebel3/<br/>名称分别为窗口句柄/类/标题/<br/>建立一个text窗口<br/>建立二个command按钮,一为开始抓取。一为退出</p><p>声明:<br/>Private&nbsp;Type&nbsp;POINTAPI<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;As&nbsp;Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;y&nbsp;As&nbsp;Long<br/>End&nbsp;Type<br/>Private&nbsp;Declare&nbsp;Function&nbsp;GetCursorPos&nbsp;Lib&nbsp;"user32"&nbsp;(lpPoint&nbsp;As&nbsp;POINTAPI)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;SetWindowPos&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;hWndInsertAfter&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;x&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;y&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;cx&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;cy&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;wFlags&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;GetClassName&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"GetClassNameA"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;lpClassName&nbsp;As&nbsp;String,&nbsp;ByVal&nbsp;nMaxCount&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;SendMessage&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"SendMessageA"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;wMsg&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;wParam&nbsp;As&nbsp;Long,&nbsp;lParam&nbsp;As&nbsp;Any)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;WindowFromPoint&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;xPoint&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;yPoint&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;GetWindowLong&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"GetWindowLongA"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;nIndex&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;GetWindowText&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"GetWindowTextA"&nbsp;(ByVal&nbsp;hwnd&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;lpString&nbsp;As&nbsp;String,&nbsp;ByVal&nbsp;cch&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long</p><p>Private&nbsp;Sub&nbsp;Command1_Click()<br/>If&nbsp;Command1.Caption&nbsp;=&nbsp;"开始抓取(&amp;S)"&nbsp;Then<br/>Timer1.Enabled&nbsp;=&nbsp;True<br/>Command1.Caption&nbsp;=&nbsp;"停止抓取(&amp;S)"<br/>Else<br/>Timer1.Enabled&nbsp;=&nbsp;False<br/>Command1.Caption&nbsp;=&nbsp;"开始抓取(&amp;S)"<br/>End&nbsp;If<br/>End&nbsp;Sub</p><p>Private&nbsp;Sub&nbsp;Command2_Click()<br/>End<br/>End&nbsp;Sub</p><p>Private&nbsp;Sub&nbsp;Form_Load()<br/>SetWindowPos&nbsp;Me.hwnd,&nbsp;-1,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;&amp;H1&nbsp;Or&nbsp;&amp;H2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'使窗体位于最顶端<br/>End&nbsp;Sub</p><p>Private&nbsp;Sub&nbsp;Timer1_Timer()<br/>On&nbsp;Error&nbsp;Resume&nbsp;Next<br/>Dim&nbsp;tPoint&nbsp;As&nbsp;POINTAPI<br/>Dim&nbsp;hWin&nbsp;As&nbsp;Long<br/>Dim&nbsp;str&nbsp;As&nbsp;String&nbsp;*&nbsp;255<br/>Dim&nbsp;Abc&nbsp;As&nbsp;String&nbsp;*&nbsp;64000<br/>Dim&nbsp;Txt(64000)&nbsp;As&nbsp;Byte<br/>GetCursorPos&nbsp;tPoint&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'获得当前鼠标位置<br/>hWin&nbsp;=&nbsp;WindowFromPoint(tPoint.x,&nbsp;tPoint.y)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'获得窗口名柄<br/>If&nbsp;hWin&nbsp;=&nbsp;Me.hwnd&nbsp;Or&nbsp;hWin&nbsp;=&nbsp;Command1.hwnd&nbsp;Or&nbsp;hWin&nbsp;=&nbsp;Command2.hwnd&nbsp;Or&nbsp;hWin&nbsp;=&nbsp;Text1.hwnd&nbsp;Then&nbsp;Exit&nbsp;Sub&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'确定窗口不在&nbsp;Form1&nbsp;中<br/>GetClassName&nbsp;hWin,&nbsp;str,&nbsp;255&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'获得窗口类<br/>SendMessage&nbsp;hWin,&nbsp;&amp;HD,&nbsp;64000,&nbsp;Txt(0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'获得窗口标题(也可使用&nbsp;API&nbsp;函数:GetWindowText,但效果不佳)<br/>Label1.Caption&nbsp;=&nbsp;"窗口名柄:&nbsp;"&nbsp;&amp;&nbsp;hWin<br/>Label2.Caption&nbsp;=&nbsp;"窗口类:&nbsp;"&nbsp;&amp;&nbsp;str<br/>Text1.Text&nbsp;=&nbsp;StrConv(Txt,&nbsp;vbUnicode)<br/>End&nbsp;Sub</p>

暴米花 发表于 2006-12-12 11:49:00

<strong>制作自己的修改器.<br/><br/></strong>Option&nbsp;Explicit<br/>Private&nbsp;Declare&nbsp;Function&nbsp;FindWindow&nbsp;Lib&nbsp;"user32"&nbsp;Alias&nbsp;"FindWindowA"&nbsp;(ByVal&nbsp;lpClassName&nbsp;As&nbsp;String,&nbsp;ByVal&nbsp;lpWindowName&nbsp;As&nbsp;String)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;GetWindowThreadProcessId&nbsp;Lib&nbsp;"user32"&nbsp;(ByVal&nbsp;hWnd&nbsp;As&nbsp;Long,&nbsp;lpdwProcessId&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;OpenProcess&nbsp;Lib&nbsp;"kernel32"&nbsp;(ByVal&nbsp;dwDesiredAccess&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;bInheritHandle&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;dwProcessId&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;WriteProcessMemory&nbsp;Lib&nbsp;"kernel32"&nbsp;(ByVal&nbsp;hProcess&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;lpBaseAddress&nbsp;As&nbsp;Any,&nbsp;lpBuffer&nbsp;As&nbsp;Any,&nbsp;ByVal&nbsp;nSize&nbsp;As&nbsp;Long,&nbsp;lpNumberOfBytesWritten&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;ReadProcessMemory&nbsp;Lib&nbsp;"kernel32"&nbsp;(ByVal&nbsp;hProcess&nbsp;As&nbsp;Long,&nbsp;ByVal&nbsp;lpBaseAddress&nbsp;As&nbsp;Any,&nbsp;lpBuffer&nbsp;As&nbsp;Any,&nbsp;ByVal&nbsp;nSize&nbsp;As&nbsp;Long,&nbsp;lpNumberOfBytesWritten&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Declare&nbsp;Function&nbsp;CloseHandle&nbsp;Lib&nbsp;"kernel32"&nbsp;(ByVal&nbsp;hObject&nbsp;As&nbsp;Long)&nbsp;As&nbsp;Long<br/>Private&nbsp;Const&nbsp;PROCESS_ALL_ACCESS&nbsp;=&nbsp;&amp;H1F0FFF<br/>Private&nbsp;hProcess&nbsp;As&nbsp;Long<br/>'下面的函数用于查找游戏<br/>Function&nbsp;FindGame()&nbsp;As&nbsp;Boolean<br/>Dim&nbsp;PID&nbsp;As&nbsp;Long,&nbsp;Gamehwnd&nbsp;As&nbsp;Long<br/>FindGame&nbsp;=&nbsp;False<br/>Gamehwnd&nbsp;=&nbsp;FindWindow(vbNullString,&nbsp;"蜘蛛")&nbsp;'查找游戏的句柄<br/>If&nbsp;(Gamehwnd&nbsp;=&nbsp;0)&nbsp;Then&nbsp;&nbsp;'如果找不到(例如游戏未运行)就退出函数<br/>MsgBox&nbsp;"没有找到蜘蛛游戏"<br/>Exit&nbsp;Function<br/>End&nbsp;If<br/>GetWindowThreadProcessId&nbsp;Gamehwnd,&nbsp;PID&nbsp;'取得进程ID<br/>hProcess&nbsp;=&nbsp;OpenProcess(PROCESS_ALL_ACCESS,&nbsp;False,&nbsp;PID)&nbsp;'以全部权力打开进程<br/>If&nbsp;(hProcess&nbsp;=&nbsp;0)&nbsp;Then&nbsp;&nbsp;'打开进程失败<br/>MsgBox&nbsp;"没有打开进程"<br/>Exit&nbsp;Function<br/>End&nbsp;If<br/>FindGame&nbsp;=&nbsp;True&nbsp;'成功!!<br/>End&nbsp;Function<br/>'回到VB的窗口设计模式,在窗体上放上两个按钮和一个文本框<br/>'一个按钮为"读取"一个为"写入",分别用于读取和写入数据<br/>'把Text1的Text设为空白<br/>Private&nbsp;Sub&nbsp;Command1_Click()<br/>Dim&nbsp;retV%,&nbsp;r&amp;<br/>'Dim&nbsp;retV%,&nbsp;r&amp;=Dim&nbsp;retV&nbsp;As&nbsp;Integer,&nbsp;r&nbsp;As&nbsp;Long<br/>If&nbsp;FindGame&nbsp;Then<br/>r&nbsp;=&nbsp;ReadProcessMemory(hProcess,&nbsp;&amp;H1011F20,&nbsp;retV,&nbsp;2,&nbsp;0)&nbsp;&nbsp;'这里重要,&amp;H1011F20为内存地址.<br/>If&nbsp;r&nbsp;=&nbsp;0&nbsp;Then<br/>MsgBox&nbsp;"读取内存不成功!"<br/>Else<br/>Text1&nbsp;=&nbsp;retV<br/>End&nbsp;If<br/>End&nbsp;If<br/>End&nbsp;Sub <p></p><p>Private&nbsp;Sub&nbsp;Command2_Click()<br/>Dim&nbsp;r&amp;<br/>If&nbsp;FindGame&nbsp;Then<br/>r&nbsp;=&nbsp;WriteProcessMemory(hProcess,&nbsp;&amp;H1011F20,&nbsp;CInt(Val(Text1)),&nbsp;2,&nbsp;0)<br/>'参数与上面的基本相同<br/>'cInt(Val(Text1))是防止输入的过程有误,,例如,输入了字母,,如果不处理程序就会出错<br/>If&nbsp;r&nbsp;=&nbsp;0&nbsp;Then<br/>MsgBox&nbsp;"写内存不成功!"<br/>Else<br/>MsgBox&nbsp;"OK"<br/>End&nbsp;If<br/>End&nbsp;If<br/>End&nbsp;Sub</p>

hing 发表于 2009-6-10 00:29:00

回复: vb一些的入门知识

sdferytuufdgsdfg
页: [1]
查看完整版本: vb一些的入门知识