可以让你运行WINDOW程序,并等待结束继续运行脚本
来源:互联网 发布:晋中市网络教育平台 编辑:程序博客网 时间:2024/05/29 08:12
The following routine will allow you to call another program from LotusScript, wait for that program to finish and continue running your script.
The Yield example in Designer help uses an obsolete API call. To illustrate this routine, create a new form and add a hotspot button. Add the code below to your button.
Code
/"Put this code in the declarations section
Declare Function GetActiveWindow Lib /"user32.dll/" () As Long
Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Const SEE_MASK_NOCLOSEPROCESS = &H40
Const SW_SHOWNORMAL = 1
Declare Function ShellExecuteEx Lib /"shell32.dll/" Alias /"ShellExecuteExA/"
(lpExecInfo As SHELLEXECUTEINFO) As Long
Const SE_ERR_FNF = 2
Declare Function WaitForSingleObject Lib /"kernel32.dll/" (Byval hHandle As Long, Byval dwMilliseconds As Long) As Long
Const INFINITE = &HFFFF
Const WAIT_TIMEOUT = &H102
/'***************************************************************************
Sub Click(Source As Button)
Dim haWnd As Long /' handle to the active window
haWnd = GetActiveWindow()
Dim sei As SHELLEXECUTEINFO /' structure used by the function
Dim retval As Long /' return value
/' Load the information needed to open C:WindowsCalc.exe into the structure.
/' Size of the structure
sei.cbSize = Len(sei)
/' Use the optional hProcess element of the structure.
sei.fMask = SEE_MASK_NOCLOSEPROCESS
/' Handle to the window calling this function.
sei.hwnd = haaaWnd
/' The action to perform: open the file.
sei.lpVerb = /"open/"
/' The file to open.
sei.lpFile = /"C:windowscalc.exe/"
/' No additional parameters are needed here.
sei.lpParameters = /"/"
/' The default directory -- not really necessary in this case.
sei.lpDirectory = /"C:windows/"
/' Simply display the window.
sei.nShow = SW_SHOWNORMAL
/' The other elements of the structure are either not used or will be set when the function returns.
retval = ShellExecuteEx(sei)
If retval = 0 Then
/' The function failed, so report the error. Err.LastDllError could also be used instead, if you wish.
Select Case sei.hInstApp
Case SE_ERR_FNF
Msgbox /"The application C:WindowsCalc.exe./"
Case Else
Msgbox /"An unexpected error occured./"
End Select
Else
/' Wait for the opened process to close before continuing. Instead of waiting once for a time of INFINITE, this example repeatedly checks to see if the is still open. This allows the DoEvents function to be called, preventing our script from appearing to lock up while it waits.
Do
Doevents
retval = WaitForSingleObject(sei.hProcess, 0)
Loop While retval = WAIT_TIMEOUT
Msgbox /"Calculator has just closed./"
End If
End Sub
- 可以让你运行WINDOW程序,并等待结束继续运行脚本
- 运行程序并等待结束
- 等待程序运行结束
- 如何让Delphi调用外部程序并等待其运行结束
- 如何让Delphi调用外部程序并等待其运行信息(如结束)
- 如何让Delphi调用外部程序并等待其运行信息(如结束)
- Delphi 调用外部程序并等待其运行结束
- Delphi 调用外部程序并等待其运行结束
- Delphi 调用外部程序并等待其运行结束
- Delphi调用外部程序并等待其运行结束
- Delphi 调用外部程序并等待其运行结束
- VC启动一个程序并等待运行结束
- [delphi]调用外部程序并等待其运行结束
- 【vs2015】C++ 程序运行并等待进程结束
- windows运行一个程序并等待其结束。
- screen命令让断开SSH/TELNET的你依然可以保持程序继续运行工作
- VBShell调用后等待程序运行结束
- MFC调用exe程序,并等待exe程序运行结束(ShellExecuteEx)
- 如何判断开发语言的复杂度?
- 迈入android开发门槛
- visual studio 2008 试用版评估期已结束的解决方法
- VS2008下使用PLC
- 转载:分享:A 标签中的target用js实现链接 百度空间_应用平台
- 可以让你运行WINDOW程序,并等待结束继续运行脚本
- ecshop模板新添商品 此商品不存在规格,请为其添加规格 的解决方法
- Android Looper
- 如何成为优秀的开发人员?
- JAVA中path和classpath分别是什么意思?
- 以16进制打印 float
- My First Blog in CSDN
- 10年软件开发教会我最重要的10件事
- 存储过程概念