Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run external program from VB6 applicatione error

Status
Not open for further replies.

emilioantonio

Technical User
Jan 18, 2006
10
IT
Hi all

I developed a VB6 application that at a certain point runs an external program (Winvam.exe) with the following code:

Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32.dll" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long

Private Const SYNCHRONIZE = &H100000
Private Const INFINITE = &HFFFFFFFF


Private Sub ProcessHandle(Process_ID As String)
Dim Process_Handle
On Error GoTo 0
Process_Handle = OpenProcess(SYNCHRONIZE, 0, Process_ID)
If Process_Handle <> 0 Then
DoEvents
Call WaitForSingleObject(Process_Handle, INFINITE)
Call CloseHandle(Process_Handle)
End If
End Sub

ProcessHandle (Shell("c:\devplan3d\surface\Winvam.exe"))

At least 1 time in three I get the following error:

Winvam: Winvam.exe - Application error
Rhe instruction at "oxoo632ce2" referenced memory at "0xc73f4a05. The memory could not be "written"

Click ok to terminate the program
Click cancel to debug the program

I never get this error when I run the program directly.

Has anyone an idea of what is going on ?

Thanks for your help

emilioantonio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top