How to determine whether a mouse is installed or mouse buttons are swapped

31 12 2008

The GetSystemMetrics function is used to determine whether a mouse is installed and whether the mouse buttons are swapped.

please check the code below,

void CheckMouse()
{  
   BOOL fResult;
  
   // Determine whether the mouse buttons are installed.
   fResult = GetSystemMetrics(SM_MOUSEPRESENT);
  
   if (fResult == 0)
   {
      printf("No mouse installed.\n");
   }
   else
   {
      printf("Mouse installed.\n");
     
      // Determine whether the buttons are swapped.
     
      fResult = GetSystemMetrics(SM_SWAPBUTTON);
     
      if (fResult == 0)
         printf("Buttons not swapped.\n");
      else printf("Buttons swapped.\n");
   }
}
Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: