Terminate and Stay Resident Programs

Can you supply me with boilerplate code for a simple console tsr program? I’m using VC++ 4.0, and I want to create a console program to check a directory every five minutes and delete zf*.* files. I don’t know if Windows NT has an event activator to fire this program every five minutes, so I had to resort to tsr programming.

First of all, all Windows applications are terminate and stay resident (TSR) applications in that they initialize themselves and then return control to the system. So I’m not sure what you mean by TSR in this case.

Beyond that, Windows has always supported timers, which direct Windows to call your application after a given time elapses. To begin the timer, just call SetTimer.

SetTimer (hWnd, 1, 5000, NULL);
The third argument specifies how much time to wait before notifying your application. The time is specified in milliseconds (1000 = 1 second). Note that the time is not precise. You should probably track the system time at each notification and determine if you want to perform your task.

Once you start the timer this way, Windows will send a WM_TIMER message to your window repeatedly as the time elapses.

case WM_TIMER:   MessageBeep(MB_OK);   break;
Use KillTimer to stop the timer messages.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may