Compartir a través de


Alternación del modo portátil/pizarra entre estados

Este tema contiene código de ejemplo que alterna el estado del indicador de modo portátil/pizarra.

int __cdecl ToggleConversionIndicator(
    __in int argc,
    __in_ecount(argc) char **argv)
{
    LPWSTR DevicePath;
    HANDLE FileHandle;
    BOOL b;
    BYTE buffer;
    HWND hwnd;
    MSG msg;

//assuming our GetDevicePath method is creating a device path using use SetupDi API
    DevicePath = GetDevicePath((LPGUID)&GUID_GPIOBUTTONS_LAPTOPSLATE_INTERFACE);
   
    FileHandle = CreateFile(DevicePath,
                            GENERIC_WRITE,
                            0,
                            NULL,
                            OPEN_EXISTING,
                            0,
                            NULL);
   
    buffer = 0;
    WriteFile(FileHandle, &buffer, sizeof(buffer), NULL, NULL);

    return 0;
}

Nota: El dispositivo indicador de modo portátil/pizarra solo se puede abrir mediante un proceso a la vez. Se producirá un error en CreateFile y GetLastError devolverá ERROR_ACCESS_DENIED cuando otro proceso ya abra el dispositivo.