当前位置: 代码迷 >> PB >> pb中查找进程有关问题
  详细解决方案

pb中查找进程有关问题

热度:171   发布时间:2016-04-29 09:27:26.0
pb中查找进程问题
global type s_process from structure

  unsignedlong structsize 

  unsignedlong usage 

  unsignedlong processid 

  unsignedlong defaultheapid 

  unsignedlong moduleid 

  unsignedlong threads 

  unsignedlong parentprocessid 

  unsignedlong classbase 

  unsignedlong flags 

  string filename 

end type

//声明api

Function Long CreateToolhelp32Snapshot(Long Flags,Long ProcessId) Library "kernel32.dll" 

Function Integer Process32First(uLong Snapshot,ref s_Process Process) Library "kernel32.dll" 

Function Integer Process32Next(uLong Snapshot,ref s_Process Process) Library "kernel32.dll" 







//代码,找avp.exe

s_Process lst_Process 

string ls_filename[100] ,ls_curexename 

ulong ln_ProcessID,ln_SameCount,ln_Snapshot,ln_Circle,ln_Count,ul_PID 

ulong ul_PIDtemp[]

Long ll_num

String ls_ExeName = 'avp.exe'



ul_PID = 0 

ln_Snapshot = CreateToolhelp32Snapshot(2,0) 

if (ln_Snapshot<1) then return 0 

lst_Process.StructSize = 296



if Process32First(ln_Snapshot,lst_Process)=0 then return 0 



//枚举当前权限下的进程 

debugbreak() 

do while true

  if Process32Next(ln_Snapshot,lst_Process)=0 then exit 

  ln_Count = ln_Count + 1 

  ls_FileName[ln_Count] = lst_Process.FileName 

  If Lower(ls_FileName[ln_Count]) = ls_ExeName Then  

  ll_num ++

  //取得进程号 

  ul_PIDtemp[ll_num] = lst_Process.ProcessID

  ul_PID = lst_Process.ProcessID  

  End If 

loop 



IF UpperBound( ul_PIDtemp ) = 0 THEN 

  MessageBox( '', '没找到' + ls_ExeName + '进程。' )

  RETURN

END IF

MessageBox( '', ls_ExeName + '进程PID为:' + String(ul_PIDtemp[1]) )

pb一运行到红色字体的时候就关闭了,请问这是怎么一回事啊?
还有就是另一颜色字体处,结构体的变量如何动态分配大小啊?

------解决方案--------------------
确实不行,明天在研究一下
------解决方案--------------------


我有PB实现进程管理的示例,如果楼主需要可发至邮箱,或者从下面地址下载
http://download.csdn.net/source/1771457
  相关解决方案