Solved

SetTimer

Posted on 1999-01-18
5
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…

740 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