#include <windows.h>
#define CTL_CODE( DeviceType, Function, Method, Access ) ( /
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) /
)
#define METHOD_BUFFERED 0
#define FILE_ANY_ACCESS 0
#define FILE_DEVICE_SPEAKER 32770
#define IOCTL_SPEAKER_ADD_NOTIFY_HWND CTL_CODE( FILE_DEVICE_SPEAKER, 2052, METHOD_BUFFERED, FILE_ANY_ACCESS )
#define IOCTL_SPEAKER_REMOVE_NOTIFY_HWND CTL_CODE( FILE_DEVICE_SPEAKER, 2053, METHOD_BUFFERED, FILE_ANY_ACCESS )
#define IOCTL_SPEAKER_GETMODE CTL_CODE( FILE_DEVICE_SPEAKER, 2054, METHOD_BUFFERED, FILE_ANY_ACCESS )
#define IOCTL_SPEAKER_SETMODE CTL_CODE( FILE_DEVICE_SPEAKER, 2055, METHOD_BUFFERED, FILE_ANY_ACCESS )
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HANDLE hSpk = CreateFile(TEXT("SPK1:"), 0, 0, NULL, OPEN_EXISTING, 0, NULL);
if(INVALID_HANDLE_VALUE != hSpk)
{
DWORD dwSpkMode = TRUE;
DeviceIoControl(hSpk, IOCTL_SPEAKER_SETMODE, &dwSpkMode, sizeof(dwSpkMode), NULL, 0, NULL, NULL);
CloseHandle(hSpk);
}
return 0;
}