快速设置戴尔latitude笔记本的触摸板和指点杆

// TouchPadSettings.cpp : Defines the entry point for the console application.
// by windviki 2010/08/31// 转载请注明出处。//// 办公用的戴尔笔记本除了触摸板,还在键盘中间有一个指点杆(point stick)// 打字很不习惯,经常会碰到。于是想禁用掉这个指点杆。发现自带的设置软件需要.Net4环境支持。// 折腾完之后成功禁用。但是很郁闷的发现设置无法保存,重启之后指点杆又启用了。// 于是祭起windbg,得到一些参数值,写了一个小程序来实现快速禁用或者开启触摸板/指点杆。设为开机启动便解决了这个问题。// 以下提供两种方法。第一种是直接用deviceiocontrol进行操作,第二种是调用其设置所用的dll导出的函数。// 至于官方控制程序无法保存设置的问题,现在发现可能是系统启动的时候没有正确的从注册表里面读取设置并应用到设备上所致。// 能否直接修改官方程序,留待后面有空研究。

#include "stdafx.h"
#include <Windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
    //直接和驱动通信
    HANDLE hApfilter = ::CreateFile(
        _T("\\.\Apfiltr"), //设备名
        GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 
        NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hApfilter == INVALID_HANDLE_VALUE)
    {
        DWORD dwErr = ::GetLastError();
        return 1;
    }
    // 111111
    // 123456
    // 1:touchpad buttons enable 
    // 2,6:touchpad enable 
    // 3:stick buttons enable 
    // 4,5:stick enable

    //char szInput[6] = {0x00, 0x00, 0x28, 0x00, 0x00, 0x00/*, 0x20, 0x00*/}; //全禁
    //char szInput[6] = {0x00, 0x00, 0x3f, 0x00, 0x00, 0x00/*, 0x15, 0x00*/}; //全开
    char szInput[6] = {0x00, 0x00, 0x28, 0x00, 0x00, 0x00};
    char szOutput[2] = {0};
    DWORD dwReturned = 0;
    if(!DeviceIoControl(hApfilter, 0xd82625b8, szInput, 6, szOutput, 2, &dwReturned, NULL))
    {
        //
    }
    ::CloseHandle(hApfilter);
    return 0;

    //——————————————————————————————————————————–
    //依靠Vxdif.dll的导出函数
    // export functions
    typedef DWORD (__stdcall *IOCTL_DisableTouchpad)(INT dwDevSelect);
    typedef DWORD (__stdcall *IOCTL_EnableWheel)(USHORT Param1);
    typedef DWORD (__stdcall *IOCTL_GetDeviceID)(DWORD hWnd, INT& dwDeviceID, INT nBuffSize);
    typedef DWORD (__stdcall *IOCTL_GetDeviceType)(DWORD hWnd, INT& dwDeviceType, INT nBuffSize);
    typedef DWORD (__stdcall *IOCTL_SelectDevice)(INT dwDevSelect);
    typedef DWORD (__stdcall *IOCTL_SetButtonEventMask)(INT dwDevSelect);
    typedef DWORD (__stdcall *IOCTL_SetButtonFunction)(DWORD hWnd, INT Param2);
    typedef DWORD (__stdcall *IOCTL_SetCornerTapOffset)(DWORD hWnd, USHORT Param2, USHORT Param3);
    typedef DWORD (__stdcall *IOCTL_SetSpeed)(DWORD hWnd, INT Param2, INT Param3);
    typedef DWORD (__stdcall *IOCTL_SetSPHwTapping)(INT Param1);
    typedef DWORD (__stdcall *IOCTL_SetSPTapSettings)(INT Param1);
    typedef DWORD (__stdcall *IOCTL_SetTapSettings)(DWORD hWnd, BYTE Param2);
    typedef DWORD (__stdcall *IOCTL_SetTouchSensitivity)(INT Param1);
    typedef DWORD (__stdcall *IOCTL_Tapping)(DWORD hWnd, INT Param2);

    HINSTANCE hVxDif = ::LoadLibrary(_T("Vxdif.dll"));

    IOCTL_DisableTouchpad pfIOCTL_DisableTouchpad = (IOCTL_DisableTouchpad)GetProcAddress(hVxDif, "IOCTL_DisableTouchpad");
    IOCTL_EnableWheel pfIOCTL_EnableWheel = (IOCTL_EnableWheel)GetProcAddress(hVxDif, "IOCTL_EnableWheel");
    IOCTL_GetDeviceID pfIOCTL_GetDeviceID = (IOCTL_GetDeviceID)GetProcAddress(hVxDif, "IOCTL_GetDeviceID");
    IOCTL_GetDeviceType pfIOCTL_GetDeviceType = (IOCTL_GetDeviceType)GetProcAddress(hVxDif, "IOCTL_GetDeviceType");
    IOCTL_SelectDevice pfIOCTL_SelectDevice = (IOCTL_SelectDevice)GetProcAddress(hVxDif, "IOCTL_SelectDevice");
    IOCTL_SetButtonEventMask pfIOCTL_SetButtonEventMask = (IOCTL_SetButtonEventMask)GetProcAddress(hVxDif, "IOCTL_SetButtonEventMask");
    IOCTL_SetButtonFunction pfIOCTL_SetButtonFunction = (IOCTL_SetButtonFunction)GetProcAddress(hVxDif, "IOCTL_SetButtonFunction");
    IOCTL_SetCornerTapOffset pfIOCTL_SetCornerTapOffset = (IOCTL_SetCornerTapOffset)GetProcAddress(hVxDif, "IOCTL_SetCornerTapOffset");
    IOCTL_SetSpeed pfIOCTL_SetSpeed = (IOCTL_SetSpeed)GetProcAddress(hVxDif, "IOCTL_SetSpeed");
    IOCTL_SetSPHwTapping pfIOCTL_SetSPHwTapping = (IOCTL_SetSPHwTapping)GetProcAddress(hVxDif, "IOCTL_SetSPHwTapping");
    IOCTL_SetSPTapSettings pfIOCTL_SetSPTapSettings = (IOCTL_SetSPTapSettings)GetProcAddress(hVxDif, "IOCTL_SetSPTapSettings");
    IOCTL_SetTapSettings pfIOCTL_SetTapSettings = (IOCTL_SetTapSettings)GetProcAddress(hVxDif, "IOCTL_SetTapSettings");
    IOCTL_SetTouchSensitivity pfIOCTL_SetTouchSensitivity = (IOCTL_SetTouchSensitivity)GetProcAddress(hVxDif, "IOCTL_SetTouchSensitivity");
    IOCTL_Tapping pfIOCTL_Tapping = (IOCTL_Tapping)GetProcAddress(hVxDif, "IOCTL_Tapping");

    if (pfIOCTL_SelectDevice)
    {
        pfIOCTL_SelectDevice(0x3f); //全开

        //pfIOCTL_SelectDevice(0x28); //全禁止
    }

    ::FreeLibrary(hVxDif);

    return 0;
}

Published by Wiz

转载于:https://www.cnblogs.com/windviki/archive/2011/08/31/2160957.html

Published by

风君子

独自遨游何稽首 揭天掀地慰生平