指定关闭某程序的软件源码(关闭程序的代码)
本文目录一览:
- 1、vb关闭其它程序代码(源码)
- 2、定时关闭某个程序的软件
- 3、E语言中按一个键(比如F1)就结束一个指定的程序的源码是什么?
- 4、各位大侠,android 关闭指定包名的程序源码,要如何实现了。类似一个程序列表,获取包名然后关闭这个程序
vb关闭其它程序代码(源码)
'按你的意思,首先判断需要关掉的进程是否存在,存在则关掉
'复制代码即可
'在VB6.0+XP SP3调试通过
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
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 CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode 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 * 1024
End Type
Const TH32CS_SNAPHEAPLIST = H1
Const TH32CS_SNAPPROCESS = H2
Const TH32CS_SNAPTHREAD = H4
Const TH32CS_SNAPMODULE = H8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = H80000000
Dim pid As Long
Dim pname As String
Private Sub taskkill(ByVal taskname As String)
Dim my As PROCESSENTRY32
Dim l As Long
Dim l1 As Long
Dim flag As Boolean
Dim mName As String
Dim i As Integer
l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If l Then
my.dwSize = 1060
If (Process32First(l, my)) Then
Do
i = InStr(1, my.szExeFile, Chr$(0))
mName = LCase$(Left$(my.szExeFile, i - 1))
If mName = LCase$(taskname) Then
pid = my.th32ProcessID
pname = mName
Dim mProcID As Long
mProcID = OpenProcess(1, -1, pid)
TerminateProcess mProcID, 0
flag = True
Else
flag = False
End If
Loop Until (Process32Next(l, my) 1)
l1 = CloseHandle(l)
End If
End Sub
'注意进程名要区分大小写
Private Sub Command1_Click()
Call taskkill("xx.exe")'如果存在进程xx.exe,则结束xx.exe
End Sub
定时关闭某个程序的软件
其实系统本身有这项功能的,打开记事本,将以下内容保存为.bat文件
(将下面cmd.exe的名字改成你的音乐播放软件的exe名)
@echo off
TASKKILL /F /IM cmd.exe /T
保存好之后,打开控制面板任务计划,添加新任务,把这个bat定时就行了,时间到了之后那个播放器就会被结束掉,用这个批处理你可以结束掉大多数的程序。
E语言中按一个键(比如F1)就结束一个指定的程序的源码是什么?
比如你写一个记事本程序,你点击.txt的文档时想用你自己写的记事本打开,设置好文件关联后,源代码如下: .版本 2.程序集 窗口程序集1.子程序 __启动窗口_创建完毕
.局部变量 命令行, 文本型, , "0"
.局部变量 数组下标, 整数型
.局部变量 文件名, 文本型取命令行 (命令行)
.如果真 (取数组成员数 (命令行) ≥ 1)
.变量循环首 (1, 取数组成员数 (命令行), 1, 数组下标)
文件名 = 文件名 + 命令行 [数组下标]
.变量循环尾 ()
编辑框1.内容 = 到文本 (读入文件 (文件名))
.如果真结束
各位大侠,android 关闭指定包名的程序源码,要如何实现了。类似一个程序列表,获取包名然后关闭这个程序
ActivityManager activityManger=(ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
ListActivityManager.RunningAppProcessInfo list=activityManger.getRunningAppProcesses();
for(int i=0;ilist.size();i++)
{
ActivityManager.RunningAppProcessInfo apinfo ==list.get(i);
if(apinfo.processName.equals(new String("包名")))
{
String[] pkgList=apinfo.pkgList;
for(int j=0;jpkgList.length;j++)
{
//2.2以上是过时指定关闭某程序的软件源码的,请用killBackgroundProcesses代替
activityManger.killBackgroundProcesses(pkgList[j]);
}
}
}