Código de ejemplo de botón de Windows
Este tema contiene un ejemplo de código que alterna el botón de Windows identificado hacia abajo y, a continuación, hacia arriba.
int __cdecl InjectButtonPress(
__in int argc,
__in_ecount(argc) char **argv)
{
LPWSTR DevicePath;
HANDLE FileHandle;
BOOL b;
BYTE buffer;
HWND hwnd;
MSG msg;
DevicePath = GetDevicePath((LPGUID)&GUID_GPIOBUTTONS_NOTIFY_INTERFACE);
FileHandle = CreateFile(DevicePath,
GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
buffer = GPIO_BUTTON_WINDOWS; //using GPIOBUTTONS_BUTTON_TYPE enum defined above
WriteFile(FileHandle, &buffer, sizeof(buffer), NULL, NULL); // send button down
buffer = GPIO_BUTTON_WINDOWS;
WriteFile(FileHandle, &buffer, sizeof(buffer), NULL, NULL); // send button up
return 0;
}