Write a utility

wase_sss

Apprentice
SUPREME
MEMBER
Joined
Aug 27, 2025
Messages
71
Reaction score
1,600
Deposit
0$
The question is as follows: Write a utility that, when launched with parameters, would adjust the screen brightness on an ASUS P750.

For example:

text
backlight.exe -up // brightness increases by 1 level
backlight.exe -down // brightness decreases by 1 level
I found this code on the forum, proposed by Sorg for PhoneAlarm, maybe it will help:

c
int batt = 5; // brightness on battery 0...7
int ext = 7; // brightness on external power 0...7

HANDLE h = CreateFile(L"BKL1:", GENERIC_READ, 0, 0, 0, 0, 0);
if(h)
{
BYTE InBuf[8] = {2, 0, 0, 0, 0, 0, 0, 0};
DWORD Res = 0;

if(batt > 7) batt = 7;
if(ext > 7) ext = 7;

if(batt >= 0)
{
HKEY key;
if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"ControlPanel\\AsusSettings\\Backlight", 0, 0, &key))
{
RegSetValueEx(key, L"BatteryPower", 0, REG_DWORD, (BYTE*)&batt, 4);
RegCloseKey(key);
}

InBuf[4] = batt;
InBuf[6] = 0;
DeviceIoControl(h, 0xA201A004, InBuf, 8, NULL, 0, &Res, NULL);
}

if(ext >= 0)
{
HKEY key;
if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"ControlPanel\\AsusSettings\\Backlight", 0, 0, &key))
{
RegSetValueEx(key, L"ExternalPower", 0, REG_DWORD, (BYTE*)&ext, 4);
RegCloseKey(key);
}

InBuf[4] = ext;
InBuf[6] = 1;
DeviceIoControl(h, 0xA201A004, InBuf, 8, NULL, 0, &Res, NULL);
}

CloseHandle(h);
}
 
Top Bottom