当在程序中运行DOS命令时如何隐藏DOS窗口并判断其结束
2007-09-26 14:54
531 查看
问:我想在程序中运行有关DOS命令,可又不想让用户看到DOS窗口,并想判断一下DOS命令是否已运行结束,难死我了? 答:你的要求也太高了,这样试试吧: 第一步:定义全局外部函数: Function long ShellExecuteA (long hwnd, string lpOperation ,String lpFile, String lpParameters, String lpDirectory, Long nShowCmd) Library "shell32.dll" Function long FindWindowA (String lpClassName , String lpWindowName ) Library "user32.dll" Function boolean IsWindow (Long hwnd ) Library "user32.dll" [用API函数,可以隐藏应用程序的窗口,但是调用bat批处理命令时需要先建立一个PIF(批处理命令的快捷键方式)文件指定执行完成后关闭窗口(其中的一个属性),否则窗口不会自行关闭。] 第二步:在窗口上建立按扭,clicked事件中包含如下Script: ulong ll_handle,lu_return string ls_path SetPointer(HourGlass!) //设置鼠标指针 //运行DOS批处理命令的快捷键方式,并将其窗口隐藏 lu_return = ShellExecutea(handle(parent), "open", "xxx.pif", "", ls_path, 0) //最后一个参数改为 4,可以显示执行情况,0为隐藏窗口 if lu_return>32 then ll_handle = 0 //循环至DOS窗口打开 Do While ll_handle = 0 ll_handle = FindWindowA("tty","xxx") yield() loop //等待DOS窗口关闭 Do While isWindow(ll_handle) Yield() Loop //应用执行完成 MessageBox("提示信息", "运行完毕!") end if
文章引用自:
相关文章推荐
- 如何调用一个程序,等待运行结束,并知晓程序运行成功与否:ShellExecuteEx;WaitForSingleObject;GetExitCodeProcess(C代码)
- Cocos2d-x 程序是如何开始运行与结束!
- Cocos2d-x 程序是如何开始运行与结束的
- 如何用DOS命令运行记事本上的JAVA小程序
- 如何让基于对话框的MFC程序一运行起来就完全隐藏
- java程序中,如何安全的结束一个正在运行的线程?interrupt()
- Cocos2d-x 程序是如何开始运行与结束的
- java程序中,如何安全的结束一个正在运行的线程?
- cocos2d-x 引擎分析:程序是如何开始运行与结束的?
- Cocos2d-x 程序是如何开始运行与结束的
- C#调用Exe文件的方法及如何判断程序调用的exe已结束
- C#如何判断我的程序已经有一个实例正在运行
- Cocos2d-x 程序是如何开始运行与结束的
- 如何判断当前程序是否运行在虚拟机内
- 如何让Delphi调用外部程序并等待其运行结束
- Cocos2d-x 程序是如何开始运行与结束的
- VC++/VS2010 Win32控制台程序 运行结束 DOS/dos窗口立刻消失/一闪而过 的解决方法整理
- C#调用Exe文件的方法及如何判断程序调用的exe已结束
- Cocos2d-X 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的[转]