G
Guest
Hi,
When I start up my device, instead of explorer.exe I am starting a VB.Net
program. The VB.Net program checks to see if I have ever aligned my ELO touch
screen (I create a file to indicate this) I call ELO's alignment program
using CreateProcess. My problem is that even though I think the calling
program is waiting for the ELO Alignment program to finish, it does not seem
to. The calling program continues on its' merry way and I only see my
alignment screen for a few seconds. I assume I am using CreateProcess
incorrectly, does any one see any problems with my code?
Thank you for your help,
Hari
Overloads Declare Function CreateProcess Lib "CoreDll.dll" (ByVal imageName
As String, ByVal cmdLine As String, ByVal lpProcessAttributes As IntPtr,
ByVal lpThreadAttributes As IntPtr, ByVal boolInheritHandles As Int32, ByVal
dwCreationFlags As Int32, ByVal lpEnvironment As IntPtr, ByVal lpszCurrentDir
As IntPtr, ByVal si As Byte(), ByVal pi As ProcessInfo) As Integer
Public Declare Function WaitForSingleObject Lib "CoreDll.dll" (ByVal Handle
As IntPtr, ByVal Wait As Int32) As Int32
Public Declare Function CloseHandle Lib "CoreDll.dll" (ByVal Handle As
IntPtr) As Int32
Public Sub Align_Me()
Dim bAlignmentOK As Boolean = False
File.Delete(alignmentPath)
While bAlignmentOK = False
Dim progPath As String = "\Windows\EloVa.exe"
Dim pi As New ProcessInfo
CreateProcess(progPath, "", pi)
Dim swAlign As StreamWriter = File.CreateText(alignmentPath)
swAlign.WriteLine("Aligned on " + Now().ToLongDateString +
Now().ToLongTimeString)
swAlign.Flush()
swAlign.Close()
If RegFlushKey(HKEY_LOCAL_MACHINE) = SUCCESS Then
If MsgBox("Click anywhere on the screen to see if the pointer follows
your finger correctly." + vbCrLf + _
"When you are satisfied that the alignment is
correct click OK, to align again click cancel.", _
MsgBoxStyle.OKCancel, "Alignment Verification") = MsgBoxResult.OK
Then
bAlignmentOK = True
End If
End If
End While
End Sub
Public Class ProcessInfo
Public hProcess As IntPtr
Public hThread As IntPtr
Public ProcessId As Int32
Public ThreadId As Int32
End Class 'ProcessInfo
Public Overloads Shared Function CreateProcess(ByVal ExeName As String,
ByVal CmdLine As String, ByVal pi As ProcessInfo) As Boolean
Dim INFINITE As Int32
INFINITE = &HFFFFFFFF
Dim WAIT_OBJECT_0 As Int32 = 0
Dim result As Int32
If pi Is Nothing Then
pi = New ProcessInfo
End If
Dim si(128) As Byte
result = CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0,
IntPtr.Zero, IntPtr.Zero, si, pi)
System.Threading.Thread.Sleep(10000)
If 0 = result Then
Return False
End If
result = WaitForSingleObject(pi.hProcess, INFINITE)
CloseHandle(pi.hThread)
CloseHandle(pi.hProcess)
If WAIT_OBJECT_0 <> result Then
Return False
End If
Return True
End Function
When I start up my device, instead of explorer.exe I am starting a VB.Net
program. The VB.Net program checks to see if I have ever aligned my ELO touch
screen (I create a file to indicate this) I call ELO's alignment program
using CreateProcess. My problem is that even though I think the calling
program is waiting for the ELO Alignment program to finish, it does not seem
to. The calling program continues on its' merry way and I only see my
alignment screen for a few seconds. I assume I am using CreateProcess
incorrectly, does any one see any problems with my code?
Thank you for your help,
Hari
Overloads Declare Function CreateProcess Lib "CoreDll.dll" (ByVal imageName
As String, ByVal cmdLine As String, ByVal lpProcessAttributes As IntPtr,
ByVal lpThreadAttributes As IntPtr, ByVal boolInheritHandles As Int32, ByVal
dwCreationFlags As Int32, ByVal lpEnvironment As IntPtr, ByVal lpszCurrentDir
As IntPtr, ByVal si As Byte(), ByVal pi As ProcessInfo) As Integer
Public Declare Function WaitForSingleObject Lib "CoreDll.dll" (ByVal Handle
As IntPtr, ByVal Wait As Int32) As Int32
Public Declare Function CloseHandle Lib "CoreDll.dll" (ByVal Handle As
IntPtr) As Int32
Public Sub Align_Me()
Dim bAlignmentOK As Boolean = False
File.Delete(alignmentPath)
While bAlignmentOK = False
Dim progPath As String = "\Windows\EloVa.exe"
Dim pi As New ProcessInfo
CreateProcess(progPath, "", pi)
Dim swAlign As StreamWriter = File.CreateText(alignmentPath)
swAlign.WriteLine("Aligned on " + Now().ToLongDateString +
Now().ToLongTimeString)
swAlign.Flush()
swAlign.Close()
If RegFlushKey(HKEY_LOCAL_MACHINE) = SUCCESS Then
If MsgBox("Click anywhere on the screen to see if the pointer follows
your finger correctly." + vbCrLf + _
"When you are satisfied that the alignment is
correct click OK, to align again click cancel.", _
MsgBoxStyle.OKCancel, "Alignment Verification") = MsgBoxResult.OK
Then
bAlignmentOK = True
End If
End If
End While
End Sub
Public Class ProcessInfo
Public hProcess As IntPtr
Public hThread As IntPtr
Public ProcessId As Int32
Public ThreadId As Int32
End Class 'ProcessInfo
Public Overloads Shared Function CreateProcess(ByVal ExeName As String,
ByVal CmdLine As String, ByVal pi As ProcessInfo) As Boolean
Dim INFINITE As Int32
INFINITE = &HFFFFFFFF
Dim WAIT_OBJECT_0 As Int32 = 0
Dim result As Int32
If pi Is Nothing Then
pi = New ProcessInfo
End If
Dim si(128) As Byte
result = CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0,
IntPtr.Zero, IntPtr.Zero, si, pi)
System.Threading.Thread.Sleep(10000)
If 0 = result Then
Return False
End If
result = WaitForSingleObject(pi.hProcess, INFINITE)
CloseHandle(pi.hThread)
CloseHandle(pi.hProcess)
If WAIT_OBJECT_0 <> result Then
Return False
End If
Return True
End Function