请问用VF检测到一个程序关闭啦

silandn 2012-08-31 01:11:54
就是这样的,点击一个按钮,运行一个程序a。当这个运行的程序a自动关闭的时候,会自动弹出一个提示框,告知a已经关闭啦,。
...全文
235 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
myperry 2012-09-16
  • 打赏
  • 举报
回复
我也想学习这个。
十豆三 2012-09-03
  • 打赏
  • 举报
回复
如果用 ShellExecute 或 WinExec ,必须单独写单代码循环判断。( 利用 Do While 。。。 Enddo)
十豆三 2012-09-03
  • 打赏
  • 举报
回复
ShellExecute 没有类似 WScript.Shell 参数3等待功能。
silandn 2012-09-01
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]

ox=CreateObject("WScript.Shell")
ox.Run("notepad.exe",1,1) && 第3个参数1,表示一直等待被调用的程序。notepad.exe 为调用的记事本程序
MessageBox('程序已关闭',64,'信息提示')
Release ox
[/Quote]

这样的方法简单有时候,不过,我还想问问,如果是ShellExecute函数该怎么写啊。如果也是加第三个1的话,提示参数太多。
十豆三 2012-08-31
  • 打赏
  • 举报
回复
ox=CreateObject("WScript.Shell")
ox.Run("notepad.exe",1,1) && 第3个参数1,表示一直等待被调用的程序。notepad.exe 为调用的记事本程序
MessageBox('程序已关闭',64,'信息提示')
Release ox
taohua300 2012-08-31
  • 打赏
  • 举报
回复
5楼是检查excel的
楼主根据自己需要,把
If Lower(m.lnval) == 'excel.exe'

改成自己需要的a。exe就可以了
taohua300 2012-08-31
  • 打赏
  • 举报
回复
Declare integer CreateToolhelp32Snapshot in win32api integer,integer
Declare integer Process32First in win32api integer,string @
Declare integer Process32Next in win32api integer,string @
Declare integer CloseHandle in win32api integer
CLEAR
lnHand = 0
lnHand = CreateToolhelp32Snapshot(3,0)
If lnHand>0
lctitle=SPACE(256)
If Process32First(lnHand,@lctitle) > 0
tln = 0
Do while Process32Next(lnHand,@lctitle)> 0
m.lnval=SUBSTR(lctitle,37,256)
m.lnval=left(m.lnval,At(Chr(0),m.lnval) - 1)
If Lower(m.lnval) == 'excel.exe'
tln = tln + 1
If tln == 1
Exit
Endif
Endif
Enddo
If tln == 0
Messagebox("程序已经被关闭",4096,"Message")
CloseHandle(lnHand)
Clear Dlls
Else
****没有关闭
Endif
Endif
CloseHandle(lnHand)
Endif

yrt888 2012-08-31
  • 打赏
  • 举报
回复
不好意思,按错了键:

DECLARE INTEGER FindWindow IN user32 STRING lpClassName,STRING lpWindowName

IF FindWindow(NULL,'某某标题')=0
.........

endif

yrt888 2012-08-31
  • 打赏
  • 举报
回复
用简单枚举进程方法如:

LOCAL oWbemLocator,oWMIService, oItems, oItem
oWbemLocator = CREATEOBJECT("WbemScripting.SWbemLocator")
oWMIService = oWbemLocator.ConnectServer(".", "root/cimv2")
oItems = oWMIService.ExecQuery("SELECT * FROM Win32_Process")
FOR EACH oItem IN oItems
MAJC=LOWER(oItem.Name)
IF MAJC='某某进程.exe'
.......
ENDIF
ENDFOR

如果该程序有固定标题,也可以这样
silandn 2012-08-31
  • 打赏
  • 举报
回复
有一个软件是a.exe,在VF的标单上有一个按钮,当点击这个按钮的时候,运行a.exe。当关闭a.exe的时候,这个VF的标单上会弹出一个提示框,“a.exe已经关闭了。”
lygcw9602 2012-08-31
  • 打赏
  • 举报
回复
不明白

2,749

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧