如何在VB.NET中使用SHELL FUNCTION [英] How can to use SHELL FUNCTION in VB.NET

查看:95
本文介绍了如何在VB.NET中使用SHELL FUNCTION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有文件:
C:\ tmp \ 01.mcr
C:\ tmp \ 02.mcr
....
C:\ tmp \ 99.mcr
我的代码是:
Dim i作为interger,nStr作为string
对于i = 1到99
nStr = right(str(100 + i),2)& ".mcr"
Shell("C:\ MacroRecorder \ MacroRecorderLite.exe"& nStr,"AppWinStyle.MinimizedFocus, True ,-1)
下一个

当我在Shell Function中设置值 TRUE 时,MacroRecorder无法单击表单中的按钮.

当我在Shell Function中设置值 FALSE 时,值i正在运行至99.

如何在FOR ... NEXT中逐步使用我的表单运行MacroRecorder(激活).

There are files:
C:\tmp\01.mcr
C:\tmp\02.mcr
....
C:\tmp\99.mcr
My code is:
Dim i as interger, nStr as string
for i=1 to 99
nStr=right(str(100+i),2) & ".mcr"
Shell("C:\MacroRecorder\MacroRecorderLite.exe " & nStr, "AppWinStyle.MinimizedFocus, True, -1)
next

When I set value TRUE in Shell Function then MacroRecorder can''t click to a button in my form.

When I set value FALSE in Shell Function then value i is running to 99.

How can to run MacroRecorder with my form (activing) step by step in FOR...NEXT.

推荐答案

Shell命令实际上是错误的使用此命令因为它将在不等待其结束的情况下启动另一个程序,或者仅在调用程序完成后才运行另一个程序,所以这是基于true/false等待值.

更好的选择是使用System.Diagnostics.Process.Start命令,在此处有一篇文章.有关如何使用它的http://www.devx.com/dotnet/Article/7914"target =" _ blank"title =" New Window> ^ ],这是多页文章,第二篇该页面显示了如何监视已启动的应用程序.
The Shell command is really the wrong one to use for this as it will either launch the other program without waiting for it to finish or will only run the other program when the calling program has finished, this is based on the true/false wait value.

A better option would be to use the System.Diagnostics.Process.Start command, there is an article here[^] on how to use it, this is a multi-page article with the second page showing how to monitor the launched application.


这篇关于如何在VB.NET中使用SHELL FUNCTION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆