I was thinking about making a TSR program in C++. I did some googling but found that most of them are using "dos.h" headers. This is obsolete and its use is frowned upon. So how can I make a simple TSR program in C++ ?

Recommended Answers

All 5 Replies

Assuming you are running Windows, the answer is, you don't. DOS TSRs required low-level access to the BIOS, and hooking an interrupt; they are notoriously badly behaved under Windows, even inside of the cosnole or a DOS box.

Under Windows, then the equivalent of a TSR is simply a program that launches without opening a window, and waits for the appropriate invocation. Usually, what you would do is put an icon in the system tray, and wait for it to be clicked to access the program. The 'classic' TSR invocation method of using some specific control-keystroke is discouraged, as it could conflict with other programs which use the same keystrokes.

Can you tell us more about the purpose and goals for this program, and why you want it to behave as a TSR?

This is obsolete and its use is frowned upon.

So are TSRs. If you're not into obsolete stuff, learn to write a Windows service (assuming Windows as the natural progression because you're talking about DOS).

So how can I code a program such that the program works in the background ?

Ah, now that would depend on the compiler you're using, at least to some degree, and whether you were using a framework of some kind (e.g., .NET, MFC) or calling Win32 directly. To start with, you would need to use a modern Windows compiler, so Turbo C++ isn't an option. Second, if you used a compiler other than Visual C++, you would need to use Win32 directly, or a third party windowing library such as Qt or wxWidgets, as the most common frameworks (MFC and .Net) are specific to Microsoft's compilers. Third, you'd need to be familiar with how to write a Windows application in general, which is quite different from writing a console application.

So how can I code a program such that the program works in the background ?

By reading my previous post: write a Windows service. Once again, I'm assuming that you're using a Windows based operating system, given the nature of the original question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.