How to change the backlight brightness level with C#?

Mar 27, 2012 at 11:41 AM

I am working on the device application, where I need to adjust the
brightness and contrast of the window ce 5.0 device.

I have some C++ code I'm using as a reference, but I'm not getting it.

void static  AdjustBrightness(BYTE bBrightNess)
{
    bool bRet = FALSE;
    HANDLE hDevBKL;   
    DWORD dwPercent=(DWORD)bBrightNess*6.4;          //3;
    hDevBKL = CreateFile(_T("BKL1:"),
                         GENERIC_READ|GENERIC_WRITE,
                         FILE_SHARE_READ|FILE_SHARE_WRITE,
                         NULL,
                         OPEN_ALWAYS,
                         0,
                         0);
       
    bRet = DeviceIoControl(hDevBKL,
                       IOCTL_BKL_SET_INTENSITY,
                       &dwPercent,
                       sizeof(dwPercent),
                       NULL,
                       0,
                       NULL,
                       NULL);
       

    if(!bRet)
    {
            SetLastError(GetLastError());
    }

I'm looking for sample code on how to change contrast and brightness on window ce 5.0 device using C# , can anyone help me out here ?