Mouse wheel using DirectInput8

Assorted credits! :P

Code:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

#include <dinput.h>
#pragma comment ( lib, "Dinput8.lib" )
#pragma comment ( lib, "Dxguid.lib" )

//constants for mouse buttons (NEW)
#define DIMOUSE_LEFTBUTTON   0
#define DIMOUSE_RIGHTBUTTON  1
#define DIMOUSE_MIDDLEBUTTON 2
#define DIMOUSE_4BUTTON      3
#define DIMOUSE_5BUTTON      4
#define DIMOUSE_6BUTTON      5
#define DIMOUSE_7BUTTON      6
#define DIMOUSE_8BUTTON      7

void Mouse( );

LPDIRECTINPUT8 g_lpdi				= NULL;
LPDIRECTINPUT8 pDI					= NULL;
LPDIRECTINPUTDEVICE8 pMouse	= NULL;

BYTE Keys[4]								= {0};

void main( )
{    
    if( FAILED( DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, 
                             IID_IDirectInput8, (VOID**)&pDI, NULL ) ) )
	{
							 printf( "Error: DirectInput8Create!\n" );
							 return;
	}

    pDI->CreateDevice( GUID_SysMouse, &pMouse, NULL );
 
    pMouse->SetDataFormat( &c_dfDIMouse2 );    
    pMouse->SetCooperativeLevel( GetConsoleWindow( ), 
		DISCL_NONEXCLUSIVE | DISCL_FOREGROUND );
    

	DIPROPDWORD dipdw;
	dipdw.diph.dwSize				= sizeof(DIPROPDWORD);
	dipdw.diph.dwHeaderSize		= sizeof(DIPROPHEADER);
	dipdw.diph.dwObj				= 0;
	dipdw.diph.dwHow				= DIPH_DEVICE;
	dipdw.dwData						= 16; // Arbitrary buffer size

	if( FAILED( pMouse->SetProperty( DIPROP_BUFFERSIZE, &dipdw.diph ) ) )
		return;

	pMouse->Acquire();

	Mouse( );

	system( "PAUSE" );
}

void Mouse( )
{
	while( 1 )
	{
		DIMOUSESTATE2 dims2; 
		ZeroMemory( &dims2, sizeof(dims2) );
	    
		if( FAILED( pMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &dims2 ) ) ) 
		{
			HRESULT Result = pMouse->Acquire();
			while( Result == DIERR_INPUTLOST ) 
				Result = pMouse->Acquire();
	    
			Sleep( 100 );
			continue; 
		}
	 
		system( "cls" );
		printf( "X Relative Pos: %i\nY Relative Pos: %i\n", dims2.lX, dims2.lY );

		if( dims2.lZ == WHEEL_DELTA || dims2.lZ == 240 || dims2.lZ == 360 ||
			dims2.lZ == 480 || dims2.lZ == 600 || dims2.lZ == 720 || 
				dims2.lZ == 840 || dims2.lZ == 960 )
			Beep( 4000, 500 );
		else if( dims2.lZ == -WHEEL_DELTA || dims2.lZ == -240 || dims2.lZ == -360 ||
			dims2.lZ == -480 || dims2.lZ == -600 || dims2.lZ == -720 || 
			dims2.lZ == -840 || dims2.lZ == -960 )
			Beep( 7000, 500 );

		if( dims2.rgbButtons[DIMOUSE_MIDDLEBUTTON] & 0x80 )
			break;

		if( dims2.rgbButtons[DIMOUSE_RIGHTBUTTON] & 0x80 )
			Beep( 1000, 500 );

		if( !( dims2.rgbButtons[DIMOUSE_LEFTBUTTON] & 0x80 ) )
			Keys[0]		= 0;
		else
		{
			if( !Keys[0] )
			{
				Beep( 10000, 500 );
				Keys[0]		= 1;
			}
		}

		Sleep( 100 );
	}
}