Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 09:13 PM
Andreas
Guest
 
Posts: n/a
Default Timing problem

Hi!

I was using a standard windows timer, but it gave an error over 9% on
a win 98 machine with no other programs running!

Bacause of this, I decided to implement windows MultiMedia timer, and
used code examples from msdn and this group. Everything works fine
when I run it from VB, but if I complie and run, I get an error (and
program termination) at the first timer event. (The .exe is ofcause
runned from the same machine as VB.)

I get the error message that '[some memory addresses] memory could not
be "read".'

My code is very, very short. Only the very nessecary rows are left and
still the error occures. (I'm quite new to work with dll's outside
VB.)

This is my code:


========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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles