Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
再定义一个TIMER控件,Inerval的值设成1000
主要代码如下
Dim ret
Dim x, ret, ret2 As Long
Private Sub Timer1_Timer()
i = i + 1
If i = 180 Then ret = Shell("d:\1.exe", 1)
If i = 480 Then ret1 = Shell("d:\2.exe", 1)
If i = 1080 Then
x = OpenProcess(0, False, ret)
ret = TerminateProcess(x, 0)
ret = closehandel(x)
End If
If i = 1680 Then
x = OpenProcess(0, False, ret2)
ret2 = TerminateProcess(x, 0)
ret2 = closehandel(x)
End If
End Sub
我在给个答案吧。新建工程,添加一个picture控件,名字改做pic1,将以下代码拷贝到编辑区,运行即可
Option Explicit
Dim BZ As Integer
'BZ=0开关关闭
'BZ=5开关开启
Private Sub Form_Load()
BZ = 0 ''假设初始的状态是关闭状态,您可以自定义
Pic1.BackColor = vbBlue
'Pic1.Picture = LoadPicture("关闭时的图片路径")
End Sub
Private Sub Pic1_Click()
If BZ = 0 Then BZ = 5 Else BZ = 0
If BZ = 0 Then
Pic1.BackColor = vbBlue
'Pic1.Picture = LoadPicture("关闭时的图片路径")
Else
Pic1.BackColor = vbRed
'Pic1.Picture = LoadPicture("打开时的图片路径")
End If
End Sub
'以上例子用背景的变换来代表图片的变换,但是同时用注释的形式给出了载如图形的语句。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)