CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
英特尔®游戏设计大赛100美元现金周周送 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  PowerBuilder >  非技术版

关于进程问题

楼主jqfeng75(冯建勤)2003-09-03 15:52:26 在 PowerBuilder / 非技术版 提问

请问如何取得指定应用的进程句柄(比如我打开了EXCEL.EXE,我要取他的进程句柄),谢谢! 问题点数:0、回复次数:6Top

1 楼Jonea(魔鬼)回复于 2003-09-03 16:05:49 得分 0

Function   long   FindWindow     (ref   string   lpClassName,   ref   string   lpWindowName)Library   "user32"  
  Function   long   GetWindowThreadProcessId     (ref   long   hwnd,ref   long   lpdwProcessId)Library   "user32"  
   
  FindWindow   返回符合指定的类名(   ClassName   )和窗口名(   WindowTitle   )的窗口句柄  
  我们把   FindWindow   函数中得到的句柄作为参数,来获得进程名柄lpdwProcessIDTop

2 楼jqfeng75(冯建勤)回复于 2003-09-03 16:11:25 得分 0

我如何用FINDWINDOW获得EXCEL.EXE的句柄,两个REF参数如何设置!Top

3 楼killerdanny(堕落的瓦拉斯塔兹)回复于 2003-09-03 16:52:46 得分 0

forward  
  global   type   w_processes   from   window  
  end   type  
  type   cb_4   from   commandbutton   within   w_processes  
  end   type  
  type   sle_1   from   singlelineedit   within   w_processes  
  end   type  
  type   cb_3   from   commandbutton   within   w_processes  
  end   type  
  type   dw_1   from   datawindow   within   w_processes  
  end   type  
  type   lb_1   from   listbox   within   w_processes  
  end   type  
  type   cb_2   from   commandbutton   within   w_processes  
  end   type  
  type   cb_1   from   commandbutton   within   w_processes  
  end   type  
  type   lb_processes   from   listbox   within   w_processes  
  end   type  
  type   cb_ok   from   commandbutton   within   w_processes  
  end   type  
  type   processentry32   from   structure   within   w_processes  
  end   type  
  end   forward  
   
  type   PROCESSENTRY32   from   structure  
  ulong dwSize  
  ulong cntUsage  
  ulong th32ProcessID  
  ulong th32DefaultHeapID  
  ulong th32ModuleID  
  ulong cntThreads  
  ulong th32ParentProcessID  
  long pcPriClassBase  
  ulong dwFlags  
  character szExeFile[260]  
  end   type  
   
  global   type   w_processes   from   window  
  integer   x   =   1056  
  integer   y   =   484  
  integer   width   =   2546  
  integer   height   =   1800  
  boolean   titlebar   =   true  
  string   title   =   "进程管理"  
  boolean   controlmenu   =   true  
  boolean   minbox   =   true  
  boolean   maxbox   =   true  
  boolean   resizable   =   true  
  long   backcolor   =   78682240  
  cb_4   cb_4  
  sle_1   sle_1  
  cb_3   cb_3  
  dw_1   dw_1  
  lb_1   lb_1  
  cb_2   cb_2  
  cb_1   cb_1  
  lb_processes   lb_processes  
  cb_ok   cb_ok  
  end   type  
  global   w_processes   w_processes  
   
  type   prototypes  
  Function   ulong   CreateToolhelp32Snapshot   (ulong   dwFlags,   ulong   th32ProcessID)   Library   "KERNEL32.DLL"  
  Function   boolean   Process32First   (ulong   hSnapshot,   ref   PROCESSENTRY32   lppe)   Library   "KERNEL32.DLL"  
  Function   boolean   Process32Next   (ulong   hSnapshot,   ref   PROCESSENTRY32   lppe)   Library   "KERNEL32.DLL"  
  Function   boolean   CloseHandle   (ref   ulong   hObject)   Library   "KERNEL32.DLL"  
  FUNCTION   boolean   TerminateProcess   (ulong   hProcess,   uint   uExitCode)   LIBRARY   "KERNEL32.DLL"  
  FUNCTION   ulong   GetCurrentProcessId()   LIBRARY   "kernel32.dll"  
  Subroutine   ExitProcess(ulong   uExitCode)   LIBRARY   "kernel32.dll"  
  FUNCTION   boolean   GetExitCodeProcess   (ulong   hProcess,   Ref   uint   lpExitCode)   LIBRARY   "KERNEL32.DLL"  
  FUNCTION   ulong   GetCurrentProcess()   LIBRARY   "kernel32.dll"  
  FUNCTION   ulong   OpenProcess(ulong   dwDesiredAccess,ulong   bInheritHandle,ulong   dwProcessId)   LIBRARY   "kernel32.dll"  
   
  end   prototypes  
  type   variables  
  nvo_process   invo_process  
  ulong il_processid[]  
  ulong   il_current_processid  
  long   il_index  
  STRING   IS_EXENAME  
  private:  
  constant   ulong TH32CS_SNAPHEAPLIST   =   1   //0x00000001  
  constant   ulong TH32CS_SNAPPROCESS     =   2   //0x00000002  
  constant   ulong TH32CS_SNAPTHREAD       =   4   //0x00000004  
  constant   ulong TH32CS_SNAPMODULE       =   8   //0x00000008  
  constant   ulong TH32CS_SNAPALL             =   TH32CS_SNAPHEAPLIST   +   TH32CS_SNAPPROCESS   +   TH32CS_SNAPTHREAD   +   TH32CS_SNAPMODULE  
  constant   ulong TH32CS_INHERIT             =   2147483648   //0x80000000  
   
  end   variables  
  on   w_processes.create  
  this.cb_4=create   cb_4  
  this.sle_1=create   sle_1  
  this.cb_3=create   cb_3  
  this.dw_1=create   dw_1  
  this.lb_1=create   lb_1  
  this.cb_2=create   cb_2  
  this.cb_1=create   cb_1  
  this.lb_processes=create   lb_processes  
  this.cb_ok=create   cb_ok  
  this.Control[]={this.cb_4,&  
  this.sle_1,&  
  this.cb_3,&  
  this.dw_1,&  
  this.lb_1,&  
  this.cb_2,&  
  this.cb_1,&  
  this.lb_processes,&  
  this.cb_ok}  
  end   on  
   
  on   w_processes.destroy  
  destroy(this.cb_4)  
  destroy(this.sle_1)  
  destroy(this.cb_3)  
  destroy(this.dw_1)  
  destroy(this.lb_1)  
  destroy(this.cb_2)  
  destroy(this.cb_1)  
  destroy(this.lb_processes)  
  destroy(this.cb_ok)  
  end   onTop

4 楼killerdanny(堕落的瓦拉斯塔兹)回复于 2003-09-03 16:55:38 得分 0

event   open;DW_1.SETTRANSOBJECT(SQLCA)  
  DW_1.RESET()  
  CB_1.TRIGGEREVENT(CLICKED!)  
  end   event  
  type   cb_4   from   commandbutton   within   w_processes  
  integer   x   =   1074  
  integer   y   =   1360  
  integer   width   =   594  
  integer   height   =   104  
  integer   taborder   =   40  
  integer   textsize   =   -9  
  integer   weight   =   400  
  fontcharset   fontcharset   =   ansi!  
  fontpitch   fontpitch   =   variable!  
  fontfamily   fontfamily   =   swiss!  
  string   facename   =   "Arial"  
  string   text   =   "查看当前进程是否运行"  
  end   type  
   
  event   clicked;if   invo_process.uf_isrunning(il_current_processid,is_exename)   then    
  messagebox("","所选进程正在运行")  
  else  
  messagebox("","所选进程没运行")  
  end   if    
   
  end   event  
  type   sle_1   from   singlelineedit   within   w_processes  
  integer   x   =   32  
  integer   y   =   1236  
  integer   width   =   2277  
  integer   height   =   104  
  integer   taborder   =   30  
  integer   textsize   =   -9  
  integer   weight   =   400  
  fontcharset   fontcharset   =   ansi!  
  fontpitch   fontpitch   =   variable!  
  fontfamily   fontfamily   =   swiss!  
  string   facename   =   "Arial"  
  long   textcolor   =   33554432  
  borderstyle   borderstyle   =   stylelowered!  
  end   type  
   
  type   cb_3   from   commandbutton   within   w_processes  
  integer   x   =   27  
  integer   y   =   1360  
  integer   width   =   343  
  integer   height   =   104  
  integer   taborder   =   20  
  integer   textsize   =   -9  
  integer   weight   =   400  
  fontcharset   fontcharset   =   ansi!  
  fontpitch   fontpitch   =   variable!  
  fontfamily   fontfamily   =   swiss!  
  string   facename   =   "Arial"  
  string   text   =   "创建进程"  
  end   type  
   
  event   clicked;if   sle_1.text   =   ""   then   return  
  if   invo_process.uf_createprocess(sle_1.text)   then  
  DW_1.RESET()  
  CB_1.TRIGGEREVENT(CLICKED!)  
  MESSAGEBOX("","进程创建成功")  
  else  
  MESSAGEBOX("","进程创建失败")  
  end   if  
  end   event  
  type   dw_1   from   datawindow   within   w_processes  
  integer   x   =   9  
  integer   y   =   8  
  integer   width   =   2304  
  integer   height   =   1192  
  integer   taborder   =   50  
  string   title   =   "none"  
  string   dataobject   =   "d_process"  
  boolean   hscrollbar   =   true  
  boolean   vscrollbar   =   true  
  boolean   livescroll   =   true  
  borderstyle   borderstyle   =   stylelowered!  
  end   type  
   
  event   clicked;if   row   >0   then  
  il_current_processid=this.object.process_exeid[row]  
  IS_EXENAME   =this.object.process_exename[row]  
  //messagebox("",il_current_processid)  
  end   if    
  end   eventTop

5 楼killerdanny(堕落的瓦拉斯塔兹)回复于 2003-09-03 16:57:08 得分 0

type   lb_1   from   listbox   within   w_processes  
  boolean   visible   =   false  
  integer   x   =   1691  
  integer   y   =   32  
  integer   width   =   736  
  integer   height   =   504  
  integer   taborder   =   40  
  integer   textsize   =   -9  
  integer   weight   =   400  
  fontcharset   fontcharset   =   ansi!  
  fontpitch   fontpitch   =   variable!  
  fontfamily   fontfamily   =   swiss!  
  string   facename   =   "Arial"  
  long   textcolor   =   33554432  
  borderstyle   borderstyle   =   stylelowered!  
  end   type  
   
  type   cb_2   from   commandbutton   within   w_processes  
  integer   x   =   727  
  integer   y   =   1360  
  integer   width   =   343  
  integer   height   =   104  
  integer   taborder   =   30  
  integer   textsize   =   -9  
  integer   weight   =   400  
  fontcharset   fontcharset   =   ansi!  
  fontpitch   fontpitch   =   variable!  
  fontfamily   fontfamily   =   swiss!  
  string   facename   =   "Arial"  
  string   text   =   "结束进程"  
  end   type  
   
  event   clicked;//invo_process.il_processID=il_current_processid  
  uint   lui_exitcode  
  //ExitProcess(0)  
  ulong   dwDesiredAccess  
  ulong   bInheritHandle  
  ulong   dwProcessId  
  ulong   lui_exitcode1  
  //messagebox("",il_current_processid)  
  if   il_current_processid   <   0   then   return  
  lui_exitcode1=OpenProcess(dwDesiredAccess,bInheritHandle,il_current_processid)  
   
  messagebox("",lui_exitcode1)  
  if   TerminateProcess(lui_exitcode1,lui_exitcode)   then    
  messagebox("",   "杀掉进程成功")  
  dw_1.reset()  
  cb_1.triggerevent(clicked!)  
  else  
  messagebox("",   "杀掉进程失败")  
  end   if  
  //messagebox(string(invo_process.il_processID),string(il_current_processid))  
  //if   invo_process.uf_DestroyProcess()   then  
  // messagebox("",   "Killed   !")  
  //else  
  // messagebox("",   "error!")  
  //end   if  
  end   event  
  type   cb_1   from   commandbutton   within   w_processes  
  integer   x   =   375  
  integer   y   =   1360  
  integer   width   =   343  
  integer   height   =   104  
  integer   taborder   =   20  
  integer   textsize   =   -9  
  integer   weight   =   400  
  fontcharset   fontcharset   =   ansi!  
  fontpitch   fontpitch   =   variable!  
  fontfamily   fontfamily   =   swiss!  
  string   facename   =   "Arial"  
  string   text   =   "进程列表"  
  end   type  
   
  event   clicked;//messagebox("",string(lul_th32ProcessID))  
  ulong lul_hSnapshot,   lul_th32ProcessID,lu_ProcessID  
   
  invo_process   =   CREATE   nvo_process  
  invo_process.il_maxtime   =   30  
  invo_process.ib_destroy_after_wait   =   true  
  invo_process.ii_windowstate   =   1  
   
  PROCESSENTRY32 lpe_processentry  
  SetNull   (lul_th32ProcessID)  
  lul_hSnapshot   =   CreateToolhelp32Snapshot   (TH32CS_SNAPPROCESS,   lul_th32ProcessID)  
  long   i  
  lb_1.Reset()  
  lb_processes.reset()  
  DW_1.RESET()  
  if   lul_hSnapshot   >   0   then  
   
  lpe_processentry.dwSize   =   296  
  if   Process32First   (lul_hSnapshot,   lpe_processentry)   then  
  do  
  lb_processes.AddItem   (lpe_processentry.szExeFile)  
  //lu_ProcessID=GetCurrentProcessId()  
  lb_1.AddItem(string(lpe_processentry.th32ProcessID))  
  //il_processid[i]=lpe_processentry.th32ProcessID  
  //i++  
  I=DW_1.INSERTROW(0)  
  DW_1.OBJECT.process_exename[I]=lpe_processentry.szExeFile  
  DW_1.OBJECT.process_exEID[I]=lpe_processentry.th32ProcessID  
  DW_1.OBJECT.dwsize[I]=lpe_processentry.dwsize  
  loop   while   Process32Next   (lul_hSnapshot,   lpe_processentry)  
  end   if  
   
  CloseHandle   (lul_hSnapshot)  
  end   ifTop

6 楼sxy73(sxy73)回复于 2004-02-17 21:39:13 得分 0

你好!看见你关于进程方面的信息,但下面的用户对象及数据窗口对象  
  是如何定义的,请赐教!  
  nvo_process   及d_process  
   
   
                            sxy73@sina.comTop

相关问题

  • 进程,进程,还是进程问题!
  • 服务进程
  • 进程问题
  • 进程问题?
  • 进程号
  • 进程退出
  • 多进程
  • win2000的进程
  • 进程边界
  • 结束进程

关键词

  • typetype
  • processesend
  • 句柄
  • within w
  • 进程
  • commandbutton
  • findwindow
  • cb
  • ref
  • process

得分解答快速导航

  • 帖主:jqfeng75

相关链接

  • PowerBuilder类图书
  • PowerBuilder类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo