我想在窗体form1中,调用一个外部程序,如:我想调用的是Grads程序,
在里面执行两条语句:
第一条语句是执行"L"+回车
第二条是执行"run e:\aa.gs"+回车
然后将这个程序的显示界面做为form1的子窗体,
应该如何实现
shell调用EXE
如是关联文件,可以建立批处理BAT文件,再用shell调用
1。第一条语句是执行"L"+回车
这是实现什么?是 Grads中显示命令行的吗?
2。第二条是执行"run e:\aa.gs"+回车
这是实现什么?是在命令行中输入的字符吗?
3。Grads可以传参数吗?
if 1。=true and 2.=true and 3.=true then
shell Grads -参数 e:\aa.gs
Gradshwnd=getwindow(...)
setparent Gradshwnd,me.hwnd
else
shell Grads
sendkeys"L{ENTER}"
sendkeys "run e:\aa.gs{ENTER}"
end if
sendkeys"L{ENTER}"
可以直接向获得焦点的可输入框输入L+回车
调用一个带参数的应用程序
shell "c:\aaa.exe 参数"
前面是路径名,加“空格”后面跟参数
例如:
strTemp = "awei2"
Shell "C:\Agent.exe " & strTemp, vbNormalFocus
aaa.exe必须能接受参数。
在aaa的代码中加入command接受参数
Private Sub Form_Load()
Dim strTemp As String
strTemp = Command
If strTemp = "" Then
MsgBox "非法登录!", , "警告"
Unload Me
End
Else
MsgBox "ok"
End If
end sub