I am trying to call a Windows API from a Notes script. I want to use the CreateProcess API to run a program and pass it parameters. I have used this in C++ & X86 ASM. Now I want to learn how to do so in a Lotus form (VB style syntax ?). I have everything working except this section. I stripped out all the Notes form code, verified that it works fine. I then tried the code below - standalone - and
I get the "Type Mismatch" pop-up.
sumamry:
call createprocess passing it the program name (full path with no long filenames) and a parameter list, several flags
including the SW_HIDE flag - keep process from showing on the desk top ( I also varied the SW_HIDE flag to see if I got a msg or DOS pop-up - nyet)
I think that I need to declare the following parameters as long pointer items: Commandline d1 & d2
But Notes will not allow any of the above items as "Long" -
example
Dim d1 as Long
and
d1 ="some parms to be passed"
gives me a red highlight "Type mismatch" on the d1 ="some parms to be passed" line
commandline - is a program in c:\windows\system32
d1 - is one set of parms
d2 - is a different set of parms
The code that Notes will accept is shown below - no errors until run time - "Type Mismatch"
Sections as follows:
After I get this code working - once - I will add some error handling routines. Right now I know that program I am trying to run exists in the path that I show above. I have admin privileges on the Windows OS and on the Notes form.
Any help appreciated - I find this hard to debug - I need to learn how to use the Notes debugger, using the Windows debugger is extremely tedious ( it works well for simpler things like attaching to simple programs - and my lack of experience in using it - )
deros68
I get the "Type Mismatch" pop-up.
sumamry:
call createprocess passing it the program name (full path with no long filenames) and a parameter list, several flags
including the SW_HIDE flag - keep process from showing on the desk top ( I also varied the SW_HIDE flag to see if I got a msg or DOS pop-up - nyet)
I think that I need to declare the following parameters as long pointer items: Commandline d1 & d2
But Notes will not allow any of the above items as "Long" -
example
Dim d1 as Long
and
d1 ="some parms to be passed"
gives me a red highlight "Type mismatch" on the d1 ="some parms to be passed" line
commandline - is a program in c:\windows\system32
d1 - is one set of parms
d2 - is a different set of parms
The code that Notes will accept is shown below - no errors until run time - "Type Mismatch"
Sections as follows:
Code:
Declarations Sections
Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
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
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Declare Function CreateProcess 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
Sub Queryopen(Source As Notesuiview, Continue As Variant)
Dim proc As PROCESS_INFORMATION
Dim Start As STARTUPINFO
Dim CommandLine As String
Commandline = "c:\windows\system32\anyfile.exe " (no long file names - ever) always as shown
Dim d1 As String
d1 = "p1 p2 p3 p4 p5 " where p1 -p8 are parms to be passed
Dim d2 As String
d2 = "p1 p2 p3 p4 p5p p6 p7 p8"
'Initialize the STARTUPINFO structure:
Start.cb = Len(Start)
Start.dwFlags = &H1
Start.wShowWindow = 0&
'run pgm 1
CreateProcess CommandLine, d1, 0&, 0&, 1&, _
&H8000&, 0&, 0&, Start, proc
'run same pgm with different parms
CreateProcess CommandLine, d2, 0&, 0&, 1&, _
&H80000&, 0&, 0&, Start, proc
End Sub
Any help appreciated - I find this hard to debug - I need to learn how to use the Notes debugger, using the Windows debugger is extremely tedious ( it works well for simpler things like attaching to simple programs - and my lack of experience in using it - )
deros68