[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SetTimer

Posted on 1999-01-18
5
Medium Priority
?
364 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 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