A
Andreas Lundgren
Hi!
I was using a windows standard timer in VB6.0 but had a
timing error over 9% on a win 98, no other applications
running.
So I decided to try the MultiMedia timer instead, and
everything works OK in the VB enviroment. But, when I make
an .ece file and run it (on the same machine as I develop
on) an error occures and the program terminates when the
first timer event occures! Error message is something
like '[some memory addresses] memory could not be "read".'
This is the very simple code I use:
========Module1======
Option Explicit
Public Declare Function timeSetEvent Lib "winmm.dll" _
(ByVal uDelay As Long, _
ByVal uResolution As Long, _
ByVal lpTimeProc As Long, _
ByVal dwUser As Long, _
ByVal fuEvent As Long) As Long
Public Declare Function timeKillEvent Lib "winmm.dll" _
(ByVal uTimerID As Long) As Long
Public Const TIME_PERIODIC = 1
Public Const TIME_CALLBACK_FUNCTION = &H0
Public Sub Main()
Form1.Show
End Sub
Public Function TimerProc(ByVal uID As Long, _
ByVal uMsg As Long, _
ByVal dwUser As Long, _
ByVal dw1 As Long, _
ByVal dw2 As Long) As Long
Form1.Print uID, uMsg, dwUser, dw1, dw2
End Function
========Form1========
Option Explicit
Dim hTimerID
Private Sub Form_Load()
hTimerID = timeSetEvent(1000, _
10, _
AddressOf Module1.TimerProc, _
1, _
TIME_PERIODIC Or TIME_CALLBACK_FUNCTION)
End Sub
Private Sub Form_Unload(Cancel As Integer)
If hTimerID <> 0 Then
timeKillEvent hTimerID
hTimerID = 0
End If
End Sub
best regards,
Andreas Lundgren
I was using a windows standard timer in VB6.0 but had a
timing error over 9% on a win 98, no other applications
running.
So I decided to try the MultiMedia timer instead, and
everything works OK in the VB enviroment. But, when I make
an .ece file and run it (on the same machine as I develop
on) an error occures and the program terminates when the
first timer event occures! Error message is something
like '[some memory addresses] memory could not be "read".'
This is the very simple code I use:
========Module1======
Option Explicit
Public Declare Function timeSetEvent Lib "winmm.dll" _
(ByVal uDelay As Long, _
ByVal uResolution As Long, _
ByVal lpTimeProc As Long, _
ByVal dwUser As Long, _
ByVal fuEvent As Long) As Long
Public Declare Function timeKillEvent Lib "winmm.dll" _
(ByVal uTimerID As Long) As Long
Public Const TIME_PERIODIC = 1
Public Const TIME_CALLBACK_FUNCTION = &H0
Public Sub Main()
Form1.Show
End Sub
Public Function TimerProc(ByVal uID As Long, _
ByVal uMsg As Long, _
ByVal dwUser As Long, _
ByVal dw1 As Long, _
ByVal dw2 As Long) As Long
Form1.Print uID, uMsg, dwUser, dw1, dw2
End Function
========Form1========
Option Explicit
Dim hTimerID
Private Sub Form_Load()
hTimerID = timeSetEvent(1000, _
10, _
AddressOf Module1.TimerProc, _
1, _
TIME_PERIODIC Or TIME_CALLBACK_FUNCTION)
End Sub
Private Sub Form_Unload(Cancel As Integer)
If hTimerID <> 0 Then
timeKillEvent hTimerID
hTimerID = 0
End If
End Sub
best regards,
Andreas Lundgren