Hey
i have a home work TSR program
anyone can help me

>> Write a progam TSR use C to turn off sound of all aplication on computer. >> If have Sound turn off it


nice if u can write code THk

Dani AI

Generated

As and noted, whether a DOS-style TSR can silence “all applications” depends entirely on the platform. A 16-bit DOS TSR can work on real DOS (or in a DOS emulator), but it cannot globally control modern Windows audio from inside NTVDM/Command Prompt on NT-based or 64-bit Windows. That distinction decides the correct approach.

If the assignment truly requires a DOS TSR, develop and test under a real DOS environment (or DOSBox). A true TSR uses the DOS "terminate-and-stay-resident" mechanism and installs hooks or directly manipulates hardware/driver state; details are hardware-specific and require inline assembly and a DOS-compatible compiler. See the basic concept at Terminate-and-stay-resident program and test in DOSBox.

If the requirement can target modern Windows, write a native Win32 program or service and call the system audio APIs instead. For Windows Vista and later use the Core Audio API (IAudioEndpointVolume) to mute the default endpoint. For older Windows you can try the multimedia API waveOutSetVolume (but it may not affect every audio stack or per-application session). See and waveOutSetVolume.

Example (Vista+ Core Audio, simplified):

#include <windows.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#pragma comment(lib, "ole32.lib")

bool SetSystemMute(bool mute) {
  CoInitialize(NULL);
  IMMDeviceEnumerator *pEnum = NULL;
  CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL,
                   __uuidof(IMMDeviceEnumerator), (void**)&pEnum);
  IMMDevice *pDevice = NULL;
  pEnum->GetDefaultAudioEndpoint(eRender, eConsole, &pDevice);
  IAudioEndpointVolume *pVol = NULL;
  pDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&pVol);
  pVol->SetMute(mute, NULL);
  pVol->Release(); pDevice->Release(); pEnum->Release();
  CoUninitialize();
  return true;
}

Recommendation: choose the DOS-TSR route only if the grader expects code running under DOS; otherwise implement a small Win32 program using the Core Audio APIs for a reliable, system-wide mute on modern Windows.

Recommended Answers

All 4 Replies

Is your real machine really DOS?

Because if you're running XP (for example), then you'll NEVER be able to turn off sound for the whole machine.

???
Mean U if I run win Xp , I will cant turn off sound?
but for example aplication run on dos

If you're using a crusty old compiler like TurboC then you're stuck.

On XP, DOS runs in a virtual machine (playpen, sandbox, whatever you want to call it). The point is, there is NO WAY it can affect the whole machine.

To do what you're suggesting, you need a Win32 compiler which is compatible with your main OS (and not just some emulation for the benefit of older things).

Windows NT based systems dont like you writing programs like that

Windows 9x and DOS wouldnt mind, but salem is right. A TSR to terminate sound wont run on NT, regardless of whether it is run in a command prompt or not. This is not a real dos prompt, but an emulation.

And yeah, turboc is ancient. Please stop using it.

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.