HOWTO: IntelliMouse: How To Add an Application to the Exceptions List During Installation

ID: Q237614


The information in this article applies to:
  • Microsoft IntelliMouse version 1.0
  • Microsoft IntelliMouse Pro version 1.0
  • Microsoft IntelliMouse TrackBall version 1.0
  • Microsoft IntelliMouse USB version 1.0
  • Microsoft IntelliPoint software versions 2.2, 2.2a, 2.2c
  • Microsoft Wheel Mouse version 1.0


SUMMARY

This article describes how to add an application to the Exceptions for Universal Scrolling list (exceptions list) during installation.


MORE INFORMATION

Description of Registry Entries

3.1. Exceptions List

Universal Scrolling cannot work everywhere: applications may use a wheel roll to zoom rather than scroll, or assign some functionality other than Panning and AutoScrolling to the middle button. To accommodate these cases, we have constructed a mechanism to exclude specified applications from our attempts to offer Universal Scrolling support.

3.1.1. Functional Description

Applications placed on the exceptions list are excluded from the Universal Scrolling functionality. Normally, these applications are shown in the dialog box and have all Universal Scrolling functionality excluded for a specific version. There are settings available only through the registry that allow access to make the entry hidden, apply it to all versions of a specified executable, as well as to turn off only some of the Universal Scrolling features. These switches are detailed in Section 3.1.3 below.

3.1.2. Detailed Exceptions List Description (Developer/Tester Definition)

Applications are initially checked to see whether they are on the exceptions list at application load time. This is simple to do in Msh_zwf.dll during DLL_PROCESS_ATTACH.

3.1.3. Registry Settings Used

The registry settings used by the exceptions list are stored in HKEY_CURRENT_USER\Control Panel\Microsoft Input Devices\Mouse\Exceptions. Beneath this key, all exceptions are enumerated. The actual number for each exception application affects only the order in which the list is traversed. Beneath each enumerated key, the following are the settings used:

  • Filename: This string value specifies the executable for which we are to exclude functionality. This is stored as file name only, with no path. (Example: Draw.exe.)


  • Version: This DWORD value specifies the version of the executable for which we are to exclude functionality. This value is obtained from (and compared against) the major and minor version numbers available from the version information. These are placed into the high and low words of this value, respectively. If no version information is available for the application, this DWORD is set to zero. If we want to exclude Universal Scrolling functionality for all versions of this application, we can set this DWORD to -1. Having said that, there is one minor adjustment. The first bit of this value is not used in these version comparisons at all. If this bit is set, the exception is hidden and does not show up in the control panel exceptions list dialog box. (Example 1: 0x80060002 is a hidden exception for an application of version 6.2. Example 2: 0x7FFFFFFF is a visible exception that excludes all versions of an application.)


  • Description: This string value specifies the description that the user sees in the exceptions list dialog box. When the user adds an exceptions list entry, this value is acquired from the Description string in the version information. If no version information is present for the file, the file name is used. (Example: Micrografx Windows Draw.)


The following settings are used for partial exceptions. An application's presence in the exceptions list signifies that all of its Universal Scrolling features should be disabled. The presence of these switches allows individual features to be enabled, one by one. All of these items use a nonzero value to signify that the switch is enabled.
  • EnableScroll: A nonzero value in this DWORD setting enables Scrolling for the listed application. This setting defaults to disabled if not present.


  • EnablePan: A nonzero value in this DWORD setting enables Panning for the listed application. This setting defaults to disabled if not present.


  • EnableAutoScroll: A nonzero value in this DWORD setting enables AutoScrolling for the listed application. This setting defaults to disabled if not present.


Sample Code


Code to enumerate HKEY_CURRENT_USER\Control Panel\Microsoft Input Devices\Mouse\Exceptions:


// ExList.cpp 
// Sample code for adding an exception to the IntelliPoint Universal Scrolling Exceptions list.

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

// 
// CONSTANTS
// 

#define BUFFER_LENGTH      256
#define UNISCROLL_SUBKEY   "Control Panel\\Microsoft Input Devices\\Mouse\\Exceptions"
#define REG_UNISCROLL_FILENAME  "Filename"
#define REG_UNISCROLL_FILEVER   "Version"
#define REG_UNISCROLL_FILEDESC  "Description"

#define FIRST_ISV_KEY     1000
#define FIRST_USER_KEY    2000

#define HIDDEN_EXCEPTION_VERSION_MASK 0x7FFFFFFF

DWORD WINAPI AddException( 
                          LPTSTR szExeName,     //File name of .exe to add. 
                          LPTSTR szDesc,        //Size of description. buffer
                          SHORT  sMajorVer,     //Major version of product.
                          SHORT  sMinorVer);    //Minor version of product.


int main(int argc, char* argv[])
{
    AddException( "Test.exe", "Description of Sample App", 1, 2);
	return 0;
}


/****************************************************************************
FUNCTION:   AddException()
PURPOSE:    This function adds the .exe pointed at to the exception list
PARAMETERS: 
RETURNS:    ERROR_SUCCESS
            other errors returned from the registry
COMMENTS: 
****************************************************************************/ 
DWORD WINAPI AddException( 
                          LPTSTR szExeName,     //File name of .exe to add. 
                          LPTSTR szDesc,        //Size of description. buffer
                          SHORT  sMajorVer,     //Major version of product.
                          SHORT  sMinorVer)     //Minor version of product.
{
   TCHAR szKeyBuf[BUFFER_LENGTH]; 
   DWORD dwBufLength  = sizeof(szKeyBuf);
   int   iLastKey = FIRST_ISV_KEY;
   int   iCurKey;
   int   iEnumIndex = 0;
   TCHAR szNewKey[BUFFER_LENGTH]; 
   DWORD dwFileVer;
   DWORD dwRetVal;
   DWORD dwResult;
   HKEY  hKey;


   // 
   //Check to see where to insert this into the list.
   // 

   //Open base mouse key.
   if (ERROR_SUCCESS == RegOpenKeyEx( (HKEY)HKEY_CURRENT_USER,
                                      UNISCROLL_SUBKEY,
                                      0,
                                      KEY_READ,
                                      &hKey ))
   {
      //Loop through all exception keys.
      while (ERROR_SUCCESS == RegEnumKeyEx( hKey,
                                            iEnumIndex++,
                                            szKeyBuf,
                                            &dwBufLength,
                                            NULL,
                                            NULL,
                                            NULL,
                                            NULL ))
      {
          //NOTE: To be thorough, you could check here for the existence of 
          //your .exe already in this list.

          iCurKey = _ttoi(szKeyBuf);

          //If not user range
          if (FIRST_USER_KEY > iCurKey)
          {
              //Keep track of the last key (for appending).
              iLastKey = max( iCurKey, iLastKey );
          }

          //Reset BufLength.
          dwBufLength = sizeof(szKeyBuf); 
      }//End of while().

      RegCloseKey(hKey);
   }//end if (RegOpenKeyEx())



   // 
   //Build the necessary strings.
   // 

   //Build our version number.
   dwFileVer = MAKELONG( sMinorVer, (HIDDEN_EXCEPTION_VERSION_MASK & sMajorVer) );
   
   //Build our reg key string.
   _tcscpy( szNewKey, UNISCROLL_SUBKEY );
   _tcscpy( &szNewKey[_tcslen(szNewKey)], "\\" );
   //Set our key to number of past last key in this list.
   _itot( iLastKey + 1, &szNewKey[_tcslen(szNewKey)], 10);


   // 
   //Add it to the list.
   // 
   if (ERROR_SUCCESS == (dwRetVal = RegCreateKeyEx( (HKEY)HKEY_CURRENT_USER,
                                                    szNewKey,
                                                    0,
                                                    0,
                                                    REG_OPTION_NON_VOLATILE,
                                                    KEY_SET_VALUE,
                                                    0,
                                                    &hKey,
                                                    &dwResult)))
   {
	   dwRetVal = RegSetValueEx(  hKey,
                                  REG_UNISCROLL_FILENAME,
                                  0,
                                  REG_SZ,
                                  (LPBYTE)szExeName,
                                  _tcslen(szExeName));

	   if (ERROR_SUCCESS == dwRetVal)
       {
           dwRetVal = RegSetValueEx(  hKey,
                                      REG_UNISCROLL_FILEDESC,
                                      0,
                                      REG_SZ,
                                      (LPBYTE)szDesc,
                                      _tcslen(szDesc));
       }

	   if (ERROR_SUCCESS == dwRetVal)
       {
           dwRetVal = RegSetValueEx(  hKey,
                                      REG_UNISCROLL_FILEVER,
                                      0,
                                      REG_DWORD,
                                      (LPBYTE)&dwFileVer,
                                      sizeof(dwFileVer));
       }

	   //Close key.
	   RegCloseKey(hKey);
   }//End of reg stuff.
                                                                            
                       
   return dwRetVal;
} 

Additional query words: exception

Keywords : kbhw kbDSupport
Version : WINDOWS:1.0,2.2,2.2a,2.2c
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: August 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.