| |||||||||||||||
Anonymous
![]() |
Dear Normunds, I hope you're OK. I'd like to ask you again some help. I need to start a Windows executable from Notes and I must to wait for its end. I made an agent from the sample of Microsoft KnowlwdgeBase sample, here it is. I've tried it with WinXPsp2 and Lotus Notes R5.0.10, R6.5.1 but does not operate, no error message, ret& = 0, retval is OK, proc is void. I've tried in WinwordBasic, it operates fine. What made I wrong? Please help me! Best regards 'ASHELL: Option Public Option Declare Private Const NORMAL_PRIORITY_CLASS = &H20& Private Const INFINITE = -1& Private 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 Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessID As Long dwThreadID 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 String,_ 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 String, _ lpStartupInfo As STARTUPINFO,_ lpProcessInformation As PROCESS_INFORMATION) As Long Declare Function CloseHandle Lib "kernel32" (Byval hObject As Long) As Long Declare Function GetExitCodeProcess Lib "kernel32" (Byval hProcess As Long, lpExitCode As Long) As Long Sub Initialize Call form_Click End Sub Sub Form_Click()
Dim retval As Long retval = ExecCmd("notepad.exe") Msgbox "Process Finished, Exit Code " & retval
End Sub Public Function ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION Dim start As STARTUPINFO Dim ret As Long Dim vbNullString As String
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
' Start the shelled application: ret& = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc) ' Wait for the shelled application to finish: ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Call GetExitCodeProcess(proc.hProcess, ret&) Call CloseHandle(proc.hThread) Call CloseHandle(proc.hProcess)
ExecCmd = ret& End Function
|