G
Guest
Hello
My build is failing when I call some api's. Could someone help fix this
code. Not sure how to declare the variables....already tried many different
ways.....Thanks
Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As System.IntPtr, _
ByVal dwMilliseconds As Integer) As Integer
Public Auto Declare Function FindWindow Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As System.IntPtr
Public Declare Auto Function PostMessage Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Boolean
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Integer, _
ByVal bInheritHandle As Boolean, _
ByVal dwProcessId As System.IntPtr) As System.IntPtr
Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByRef lpdwProcessId As System.IntPtr) As System.IntPtr
Dim hWindow As Long
Dim hThread As Long
Dim hProcess As Long
Dim lProcessId As Long
Dim lngResult As Long
Dim lngReturnValue As Long
Dim iLoopCnt As Integer
hWindow = FindWindow(vbNullString, "(Inactive " & sDir & "\XXXX.EXE)")
hThread = GetWindowThreadProcessId(hWindow, lProcessId)
hProcess = OpenProcess(SYNCHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWindow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleObject(hProcess, 20000)
My build is failing when I call some api's. Could someone help fix this
code. Not sure how to declare the variables....already tried many different
ways.....Thanks
Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As System.IntPtr, _
ByVal dwMilliseconds As Integer) As Integer
Public Auto Declare Function FindWindow Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As System.IntPtr
Public Declare Auto Function PostMessage Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Boolean
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Integer, _
ByVal bInheritHandle As Boolean, _
ByVal dwProcessId As System.IntPtr) As System.IntPtr
Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByRef lpdwProcessId As System.IntPtr) As System.IntPtr
Dim hWindow As Long
Dim hThread As Long
Dim hProcess As Long
Dim lProcessId As Long
Dim lngResult As Long
Dim lngReturnValue As Long
Dim iLoopCnt As Integer
hWindow = FindWindow(vbNullString, "(Inactive " & sDir & "\XXXX.EXE)")
hThread = GetWindowThreadProcessId(hWindow, lProcessId)
hProcess = OpenProcess(SYNCHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWindow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleObject(hProcess, 20000)