Please be aware that this does not persist across power cycles. You will need to run this code upon OS launch if you want the functionality to persist.
Code:
DWORD PIC_IO_GET_REG = 0x7;
DWORD PIC_IO_SET_REG = 0x8;
/* turn on/off F4 power-off function*/
//get current value
g_hPWDevice = CreateFile(TEXT("PIC1:"), GENERIC_READ|GENERIC_WRITE, 0, NULL,OPEN_EXISTING, 0, NULL);
BYTE reg[2];
reg[0] = 0xc;
if (DeviceIoControl(g_hPWDevice, PIC_IO_GET_REG ,reg,sizeof(BYTE), reg+1, sizeof(BYTE),NULL,NULL))
{
}else{
}
reg[0]=0xC;
if(_wtoi((const wchar_t*)argv[1])){
printf("Turn on key F4 power-off function ");
//enable
reg[1]|=0x20;
}else{
//disable
printf("Turn off key F4 power-off function ");
reg[1]&=~0x20;
}
//set the value
if (DeviceIoControl(g_hPWDevice, PIC_IO_SET_REG ,reg,2*sizeof(BYTE), NULL, 0,NULL,NULL))
{
printf("succeeded.\r\n");
}else{
printf("failed!\r\n");
}
if(!CloseHandle(g_hPWDevice))
{
return 0;
};
Also, command line utility for doing so:
http://www.qsicorp.com/engfiles/Support/Apps/CE6_ARM/M4KeyPowerOffCE.zipcommand line usage to DISABLE powering functionality of button 4:
m4keypoweroffce 0
command line usage to ENABLE powering functionality of button 4:
m4keypoweroffce 1