首先启动vb6.0,执行文件-新建命令,d出新建工程对话框,在该对话框中选择标准的exe后点击打开按钮,进入vb程序主界面。
在主界面中,按住鼠标左键按住窗体周围的任意一个小正方形进行拖拽,调节窗体的大小,直至自己满意为止。
Option ExplicitPrivate Sub Form_Load()
Randomize
Label1.Caption = Int((Rnd * (999999 - 100000 + 1)) + 100000) '生成100000-999999之间的随机数
Timer1.Interval = 1000 '一秒一次
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static n As Integer
n = n + 1
If n = 60 Then '一秒一次,累加到60此即60秒
n = 0
Randomize
Label1.Caption = Int((Rnd * (999999 - 100000 + 1)) + 100000)
End If
End Sub
有问题请追问,满意请采纳,加油!
这个不难办到你用一个新的模块将下面的代码放进去
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 260
End Type
Private Const PROCESS_QUERY_INFORMATION = 1024
Private Const PROCESS_VM_READ = 16
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Const TH32CS_SNAPPROCESS = &H2
Public Function TestProcIsRunning(ByVal ProcName As String) As Boolean
Dim hFindProc As Long
hFindProc = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
Dim ProcData As PROCESSENTRY32
ProcData.dwSize = Len(ProcData)
Process32First hFindProc, ProcData
While (Process32Next(hFindProc, ProcData) = 1)
Dim sPro As String
sPro = Left(UCase(ProcData.szExeFile), InStr(UCase(ProcData.szExeFile), Chr(0)) - 1)
If sPro = UCase(ProcName) Then
CloseHandle hFindProc
TestProcIsRunning = True
Exit Function
End If
Wend
CloseHandle hFindProc
TestProcIsRunning = False
End Function
然后你用一个timer来实现判断就可以啦
Private Sub Timer1_Timer()
If TestProcIsRunning("你要判断的进程名") = True Then
Shell "调用这个程序的路径", vbHide''' 你写双进程源码的时候最好要隐藏程序
End If
End Sub
你好,双进程我也写过,至于编译后运行很容易被360拦截掉的,不过用来练手也感觉不错..
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)