Windows Access Violation closing HyperACCESS in VB Program
When my Visual Basic program attempts to shutdown HyperACCESS, I receive an application error:
“An application error has occurred and an application error log is being generated. HAWIN32.exe Exception: access violation (0xc0000005)
, Address: 0x110a5c40”.
This problem occurs when haTerminate is releasing the HyperACCESS API resources and Set HyperACCESS = Nothing runs before the haTerminate is complete.
The following code segment is an example of how to get around this problem. The code inserts a short delay to provide HyperACCESS time to finish shutting down before VB ends.
Dim HyperACCESS As Object
Dim haScript As Object
Dim Start As Long
Dim PauseTime As Integer
Set HyperACCESS = CreateObject (“HAWIN32”)
Set haScript = HyperACCESS.haInitialize(“Script_Name”)
‘ Functional code would be placed here
haScript.haWaitForConnection 2, 10000
‘ Set duration
PauseTime = 5
‘ Set start time
Start = Timer
Do While Timer < Start + PauseTime
‘ Yield to other processes
Set haScript = Nothing
Set HyperACCESS = Nothing