OpenNTF.org - Run application from LS
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Run application from LS 
Rating:
Rating: 1 , Number of votes: 1 
Contributor:
Andrew Jones 
Category:
Lotusscript 
Type:
API Functions 
Last Modified:
17 Jun 2002 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Public Sub RunApp (program$)
Usage / Example
(Declarations)

Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type


Declare Function WaitForSingleObject Lib "kernel32" (Byval hHandle As Long, Byval dwMilliseconds As Long) As Long
Declare Function CreateProcessA Lib "kernel32" (Byval lpApplicationName As Long, Byval lpCommandLine As String, Byval lpProcessAttributes As Long, Byval lpThreadAttributes As Long, Byval bInheritHandles As Long, Byval dwCreationFlags As Long, Byval lpEnvironment As Long, Byval lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function CloseHandle Lib "kernel32" (Byval hObject As Long) As Long
Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (Byval hObject As Long, Byval ExitCode As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&

Public Sub RunApp (program$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
structure:
start.cb = Len(start)
ret& = CreateProcessA(0&, program$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
ret& = CloseHandle(proc.hProcess)
End Sub

Sub Click(Source As Button)
RunApp("C:\Program Files\Accessories\wordpad.exe")
MsgBox "Wordpad has finished"
End Sub

 Comments
Posted by David Jamieson on 08/26/2004 09:56:45 AMRe: Run application from LS
PROCESS_INFORMATION type missing!
Posted by Alexandre Leduc on 02/10/2005 04:32:27 PMHere is the definition of PROCESS_INFORMATION
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
 Add your comment!