PB 三种获取IP的方法 以及 杀掉进程

版权声明:所有文章,欢迎评论,欢迎转载。 https://blog.csdn.net/yangjinchao/article/details/79962533
下载网址

https://download.csdn.net/download/yangjinchao/10353101



function long CreateToolhelp32Snapshot(ulong dwFlags, ulong th32ProcessID) library "kernel32"
function boolean Process32First(long hSnapshot, ref PROCESSENTRY32 lppe) library "kernel32"
function boolean Process32Next(long hSnapshot, ref PROCESSENTRY32 lppe) library "kernel32"
function boolean Module32First(long hSnapshot, ref MODULEENTRY32 lpme) library "kernel32"
function boolean Module32Next(long hSnapshot, ref MODULEENTRY32 lpme) library "kernel32"
function boolean Thread32First(ulong hSnapshot, ref THREADENTRY32 lpte) library "kernel32"
function boolean Thread32Next(ulong hSnapshot, ref THREADENTRY32 lpte) library "kernel32"
function boolean CloseHandle(long hObject) library "kernel32"
FUNCTION ulong OpenProcess(ulong dwDesiredAccess,ulong bInheritHandle,ulong dwProcessId) LIBRARY "kernel32.dll " 
FUNCTION ulong ReadProcessMemory(ulong hProcess,ulong lpBaseAddress,ref blob lpBuffer,ulong nSize,ref ulong lpNumberOfBytesWritten) LIBRARY "kernel32.dll " 
FUNCTION ulong TerminateProcess(ulong hProcess,ulong uExitCode) LIBRARY "kernel32.dll"


//====================================================================
// 函数: w_main::kill_proc()
//--------------------------------------------------------------------
// 描述: kill掉指定进程。
//--------------------------------------------------------------------
// 参数:
// 	value	string	app_proc	
//--------------------------------------------------------------------
// 返回值:  boolean
//--------------------------------------------------------------------
// 修改历史: 
//	
//====================================================================


Long ll_hSnapshot,ll_th32ProcessID
Long u_pid,hwdprocess

PROCESSENTRY32 lpe_ProcessEntry
constant long TH32CS_SNAPHEAPLIST = 1
constant long TH32CS_SNAPPROCESS  = 2
constant long TH32CS_SNAPTHREAD   = 4
constant long TH32CS_SNAPMODULE   = 8
ULONG PROCESS_TERMINATE = 0001


SetNull(ll_th32ProcessID)
//获取当前进程快照句柄
ll_hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,ll_th32ProcessID)
if ll_hSnapshot > 0 then
 	//初试化结构PROCESSENTRY32大小
 	lpe_processentry.dwSize = 296
 	//获取所有进程列表
 	if Process32First(ll_hSnapshot,lpe_ProcessEntry) then
 		Do 
   		if lpe_processentry.szExeFile = app_proc then
    			u_pid = lpe_processentry.th32ProcessID
    			exit
   		end if
  		Loop While Process32Next(ll_hSnapshot,lpe_ProcessEntry)
 	end if
 	CloseHandle(ll_hSnapshot)
end if

if u_pid = 0 then return false
	hwdprocess = OpenProcess(PROCESS_TERMINATE,1,u_pid)
if hwdprocess = 0 then return false

if TerminateProcess(hwdprocess,0) <> 0 then 
 	return true
else
 	return false
end if

阅读更多
换一批

没有更多推荐了,返回首页