With NetDCU i can use tool ndcucfg and command backlight on/off to switch on/off the backlihgt. But how can i do this from my application ?
-
-
Take a look at the following code for backlight control.
Code- #define BACKLIGHTCOMMAND 6153
- #define BACKLIGHT_CMD_ON 0
- #define BACKLIGHT_CMD_OFF 1
- #define BACKLIGHT_CMD_GET 2
- struct ContrastCmdInputParm
- {
- int command;
- int parm;
- };
- int m_nBacklightEsc=BACKLIGHTCOMMAND;
- BOOL CCmdIntp::CmdBacklightOn(void)
- {
- struct ContrastCmdInputParm ContrastParm, RetParm;
- HDC DCLCD;
- int iRes;
- TCHAR szDllName[50] = _T("ddi.dll");
- ContrastParm.command = BACKLIGHT_CMD_ON;
- ContrastParm.parm = 0;
- CRegKey cKey;
- if( ERROR_SUCCESS == cKey.Open( HKEY_LOCAL_MACHINE, _T("System\\GDI\\Drivers")) )
- {
- cKey.QueryValue( _T("Display"), szDllName );
- }
- Assert(DCLCD = CreateDC(szDllName, NULL, NULL, NULL));
- if( 0 > (iRes = ExtEscape(DCLCD, m_nBacklightEsc, sizeof (struct ContrastCmdInputParm), (LPCSTR)&ContrastParm, sizeof (struct ContrastCmdInputParm), (LPSTR)&RetParm)) ) // second two parameters can be, (0, NULL) but we assign/allocate them for similar (see two strings upper) reasons
- {
- Error( 224 );
- return FALSE;
- }
- else if (iRes > 0)
- {
- if (0 == DeleteDC(DCLCD))
- return TRUE;
- else
- return FALSE;
- }
- if (0 != DeleteDC(DCLCD))
- return FALSE;
- return TRUE;
- }
- BOOL CCmdIntp::CmdBacklightOff(void)
- {
- struct ContrastCmdInputParm ContrastParm, RetParm;
- HDC DCLCD;
- int iRes;
- TCHAR szDllName[50] = _T("ddi.dll");
- ContrastParm.command = BACKLIGHT_CMD_OFF;
- ContrastParm.parm = 0;
- CRegKey cKey;
- if( ERROR_SUCCESS == cKey.Open( HKEY_LOCAL_MACHINE, _T("System\\GDI\\Drivers")) )
- {
- cKey.QueryValue( _T("Display"), szDllName );
- }
- Assert(DCLCD = CreateDC(szDllName, NULL, NULL, NULL));
- if( 0 > (iRes = ExtEscape(DCLCD, m_nBacklightEsc, sizeof (struct ContrastCmdInputParm), (LPCSTR)&ContrastParm, sizeof (struct ContrastCmdInputParm), (LPSTR)&RetParm)) )
- {
- Error( 225 );
- return FALSE;
- }
- else
- {
- if (iRes > 0)
- {
- if (0 == DeleteDC(DCLCD))
- return TRUE;
- else
- return FALSE;
- }
- }
- if (0 != DeleteDC(DCLCD))
- return FALSE;
- return TRUE;
- }