1
- PrivateDeclareFunctionCreateToolhelp32SnapshotLib"kernel32"(ByValdwFlagsAsLong,ByValth32ProcessIDAsLong)AsLong
- PrivateDeclareFunctionProcess32FirstLib"kernel32"(ByValhSnapshotAsLong,lppeAsPROCESSENTRY32)AsLong
- PrivateDeclareFunctionProcess32NextLib"kernel32"(ByValhSnapshotAsLong,lppeAsPROCESSENTRY32)AsLong
- PrivateDeclareFunctionCloseHandleLib"kernel32"(ByValhObjectAsLong)AsLong
- PrivateDeclareFunctionOpenProcessLib"kernel32"(ByValdwDesiredAccessAsLong,ByValblnheritHandleAsLong,ByValdwAppProcessIdAsLong)AsLong
- PrivateDeclareFunctionTerminateProcessLib"kernel32"(ByValApPHProcessAsLong,ByValuExitCodeAsLong)AsLong
- PrivateTypePROCESSENTRY32
- dwSizeAsLong
- cntUsageAsLong
- th32ProcessIDAsLong
- th32DefaultHeapIDAsLong
- th32ModuleIDAsLong
- cntThreadsAsLong
- th32ParentProcessIDAsLong
- pcPriClassBaseAsLong
- dwFlagsAsLong
- szExeFileAsString*1024
- EndType
- ConstTH32CS_SNAPHEAPLIST=&H1
- ConstTH32CS_SNAPPROCESS=&H2
- ConstTH32CS_SNAPTHREAD=&H4
- ConstTH32CS_SNAPMODULE=&H8
- ConstTH32CS_SNAPALL=(TH32CS_SNAPHEAPLISTOrTH32CS_SNAPPROCESSOrTH32CS_SNAPTHREADOrTH32CS_SNAPMODULE)
- ConstTH32CS_INHERIT=&H80000000
- DimpidAsLong
- DimpnameAsString
- PrivateSubtaskkill(ByValtasknameAsString)
- DimmyAsPROCESSENTRY32
- DimlAsLong
- Diml1AsLong
- DimflagAsBoolean
- DimmNameAsString
- DimiAsInteger
- l=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0)
- IflThen
- my.dwSize=1060
- If(Process32First(l,my))Then
- Do
- i=InStr(1,my.szExeFile,Chr$(0))
- mName=LCase$(Left$(my.szExeFile,i-1))
- IfmName=LCase$(taskname)Then
- pid=my.th32ProcessID
- pname=mName
- DimmProcIDAsLong
- mProcID=OpenProcess(1&,-1&,pid)
- TerminateProcessmProcID,0&
- flag=True
- Else
- flag=False
- EndIf
- LoopUntil(Process32Next(l,my)<1)
- l1=CloseHandle(l)
- EndIf
- EndIf
- EndSub
- '×¢Òâ½ø³ÌÃûÒªÇø·Ö´óСд
- PrivateSubCommand1_Click()
- '
- Calltaskkill("calc.exe")
- EndSub