求一个VB写的小程序代码,简单的,但是我不会,求代码~!
我的要求是:当检测到某程序1.exe运行的时候,若电脑再打开一个1.exe,则把另1个1.exe其实我的目的就是:由于我朋友和我同一路游器,,他玩游戏经常双开甚至多开.....
我的要求是:
当检测到某程序1.exe运行的时候,若电脑再打开一个1.exe,则把另1个1.exe
其实我的目的就是 : 由于我朋友和我同一路游器,,他玩游戏经常双开甚至多开..搞得俺很卡..我希望有人帮我写好这么一个程序. 然后我自己用VB生成~~弄到他电脑设置自启动...谢谢~~本人VB菜鸟...求完整代码~!
当检测到某程序1.exe运行的时候,若电脑再打开一个1.exe,则把另1个多开的1.exe关闭 展开
当检测到某程序1.exe运行的时候,若电脑再打开一个1.exe,则把另1个1.exe
其实我的目的就是 : 由于我朋友和我同一路游器,,他玩游戏经常双开甚至多开..搞得俺很卡..我希望有人帮我写好这么一个程序. 然后我自己用VB生成~~弄到他电脑设置自启动...谢谢~~本人VB菜鸟...求完整代码~!
当检测到某程序1.exe运行的时候,若电脑再打开一个1.exe,则把另1个多开的1.exe关闭 展开
4个回答
展开全部
Option Explicit
'加一个timer控件即可
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As LongOption Explicit
'加一个timer控件即可
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Const MAX_PATH As Integer = 260
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 * MAX_PATH
End Type
Const TH32CS_SNAPheaplist = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPthread = &H4
Const TH32CS_SNAPmodule = &H8
Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
Private Sub form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim i As Long, lPid As Long
Dim Proc As PROCESSENTRY32
Dim Tname As String
Dim hSnapShot As Long
Dim TC As Long
Dim lphand As Long
hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程“快照”的句柄
Proc.dwSize = Len(Proc)
lPid = ProcessFirst(hSnapShot, Proc) '获取第一个进程的PROCESSENTRY32结构信息数据
i = 0
Do While lPid <> 0 '当返回值非零时继续获取下一个进程
Tname = Left(Proc.szExeFile, InStr(Proc.szExeFile, Chr(0)) - 1)
If Tname = "1.exe" Then
TC = TC + 1
If TC = 2 Then
lphand = OpenProcess(1&, True, Proc.th32ProcessID) '获取进程句柄
TerminateProcess lphand, 0&
CloseHandle lphand
CloseHandle hSnapShot '关闭进程“快照”句柄
Exit Sub
End If
End If
i = i + 1
lPid = ProcessNext(hSnapShot, Proc) '循环获取下一个进程的PROCESSENTRY32结构信息数据
Loop
CloseHandle hSnapShot '关闭进程“快照”句柄
End Sub
'楼上的都太狠了,这么简单的代码也要钱
'加一个timer控件即可
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As LongOption Explicit
'加一个timer控件即可
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Const MAX_PATH As Integer = 260
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 * MAX_PATH
End Type
Const TH32CS_SNAPheaplist = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPthread = &H4
Const TH32CS_SNAPmodule = &H8
Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
Private Sub form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim i As Long, lPid As Long
Dim Proc As PROCESSENTRY32
Dim Tname As String
Dim hSnapShot As Long
Dim TC As Long
Dim lphand As Long
hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程“快照”的句柄
Proc.dwSize = Len(Proc)
lPid = ProcessFirst(hSnapShot, Proc) '获取第一个进程的PROCESSENTRY32结构信息数据
i = 0
Do While lPid <> 0 '当返回值非零时继续获取下一个进程
Tname = Left(Proc.szExeFile, InStr(Proc.szExeFile, Chr(0)) - 1)
If Tname = "1.exe" Then
TC = TC + 1
If TC = 2 Then
lphand = OpenProcess(1&, True, Proc.th32ProcessID) '获取进程句柄
TerminateProcess lphand, 0&
CloseHandle lphand
CloseHandle hSnapShot '关闭进程“快照”句柄
Exit Sub
End If
End If
i = i + 1
lPid = ProcessNext(hSnapShot, Proc) '循环获取下一个进程的PROCESSENTRY32结构信息数据
Loop
CloseHandle hSnapShot '关闭进程“快照”句柄
End Sub
'楼上的都太狠了,这么简单的代码也要钱
展开全部
这位朋友,你能这样想说明你对网络还是有一定的研究。可是就拿魔兽世界来说吧,双开,多开都占不了什么网络的,网游对数据传输实时性要求很高的,只需要畅通的网络,但自己并不占很多带宽,你想想,他多开卡他自己一定不会多开了。你检查下他电脑是不是装了什么软件限制你看电影下载的吧,最主要的是他也怕你下电影卡死他。你装个ARP防火墙试试,360也有这功能的,还可以查看本机网络流量的。看看也进程里是不是有什么自动更新什么的。PPS也有个加速器随系统启动的,上传东西,好可恨的。祝你上网开心。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你出多少钱啊!
加我
615853728
加我
615853728
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
20元帮你搞定
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询