vb.net创建多进程,c语言创建多进程
VB.net 如何设计多线程运行
Sub Main()
创新互联公司自2013年创立以来,先为贵南等服务建站,贵南等地企业,进行企业商务咨询服务。为贵南企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
Dim thr As Thread
For Pi As Integer=0 To 4 //启用5线程
MulParams =Pi vbTab sFile vbTab dFile vbTab 1 vbTab DelN vbTab cr vbTab cg vbTab cb vbTab IndexI
GlobalParamas(pi)=MulParams .Split(vbTab)
thr=New Thread(AddressOf MyMulThreadCaller)
thr.Start() //启动多线程进程
Application.DoEvents
Next
End Sub
各们,请教怎么使用vb.net编写两个进程间消息
两个方法
1.
要接收的窗口先使用FindWindow这个api获得句柄
调用SetForegroundWindow使其获得焦点并选中
调用.net方法:SendKeys.Send方法发送
2.使用API的SendInput
Vb 多进程技术
调用 2.exe 用 shell 方法就可以了.不用多说.
至于检测 5个 2.exe 是否全都结束的方法,可以在 1.exe 中添加1个TIMER ,设定每隔1秒遍历系统进程表.]
找出系统进程中 2.exe 的个数,若为 0个 则显示"处理完成"
遍历进程需要调用API:
Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const MAX_PATH As Integer = 260
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 * MAX_PATH
End Type
Const TH32CS_SNAPheaplist = H1
Const TH32CS_SNAPPROCESS = H2
Const TH32CS_SNAPthread = H4
Const TH32CS_SNAPmodule = H8
Public Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
'下面的"GetCount" 函数用于返回 2.exe 的个数:
Public Function GetCount()
Dim i As Long, lPid As Long
Dim k As Long
Dim Proc As PROCESSENTRY32
Dim hSnapShot As Long
hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程“快照”的句柄
Proc.dwSize = Len(Proc)
lPid = ProcessFirst(hSnapShot, Proc) '获取第一个进程的PROCESSENTRY32结构信息数据
i = 0
k = 0
Do While lPid 0
If InStr(1, Proc.szExeFile, "2.exe", vbTextCompare) 0 Then
k = k + 1
End If
i = i + 1
lPid = ProcessNext(hSnapShot, Proc) '循环获取下一个进程的PROCESSENTRY32结构信息数据
Loop
CloseHandle hSnapShot '关闭进程“快照”句柄
IsDone = k
End Function
网站题目:vb.net创建多进程,c语言创建多进程
浏览地址:http://scjbc.cn/article/heodei.html