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

ID: Q237614


The information in this article applies to:


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:

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.

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