Solved

SetTimer

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MSDN Subscription - Azure and NFP's 3 71
Example of WebAPI 7 33
SSIS 2010 Convert to SSIS 2013 On Different Box 3 59
Please explain the parts of these 2 LINQ expressions 3 29
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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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