Solved

SetTimer

Posted on 1999-01-18
5
356 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

830 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