Vb制作小程序

2024-12-26 01:56:55
推荐回答(4个)
回答1:

这个不难办到

你用一个新的模块将下面的代码放进去

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拦截掉的,不过用来练手也感觉不错..

回答2:

使用WINDOWS API中的相关进程函数

回答3:

有些看不懂你的思路
你是想cmduser1点了发送,然后他自己锁定,转为cmduser2接受
cmduser2接受后再由cmduser2发送还是又从cmduser1发送出来
如果是cmduser1再发送,那你就需要锁死cmduser2,text2,解锁cmduser1,text1,同时设定cmduser1的Caption值
如果是cmduser2发送,那你就需要锁死cmduser1,text1,解锁cmduser2,text2,同时设定cmduser2的Caption值
cmduser1.SetFocus,如果cmduser1.Enabled
=
False就会出错,只有在TRUE的状态下才能执行这个语句

回答4:

学校教的是在保持窗体激活状态下才能记录打印ASCII码
保存的为txt文档需要用open语句。百度下吧。
具体详尽的方法可以百度:vb
键盘钩子