Solved

SetTimer

Posted on 1999-01-18
5
352 Views
Last Modified: 2013-12-03
How can I use SetTimer in a NT Service ? If it cannot, any method can be instead ?

Andrew
0
Comment
Question by:andrewyu
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
nil_dib earned 0 total points
ID: 1418900
You can use the SetTimer from the Win32 API:

unsigned nIDTimer = ::SetTimer( NULL, 0, 100/*millisec*/, &CMyApp::ProcTimer);
if (!m_nIDTimer)
    return false;

Write a static method which is called when the timer ellapses.

Header file:
static void CALLBACK EXPORT TimerProc( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );

Cpp file:
void CMyApp::TimerProc( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{
   // do something




0
 

Author Comment

by:andrewyu
ID: 1418901
Yes, I did the same thing before but it cannot work in the NT service !

Andrew
0
 
LVL 11

Expert Comment

by:alexo
ID: 1418902
1. Use waitable timer objects instead of timers.
2. Assign an appropriate amount of points to your questions (50=easy, etc...)
0
 

Author Comment

by:andrewyu
ID: 1418903
Sorry, I cannot assign the the point right now ! But, I also don't have 50 point at this moment !

Anyway, do you think Sleep is a good ? By the way, which API is response for your point 1 ?

Andrew
0
 
LVL 11

Expert Comment

by:alexo
ID: 1418904
>> I also don't have 50 point at this moment !
http://www.experts-exchange.com/info/buypoints.html

>> Anyway, do you think Sleep is a good ?
No but it will do in a pinch.

>>  which API is response for your point 1?
CreateWaitableTimer()

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now