![]() |
Display/Monitor: SetBrightness mit WMI ab Windows VISTA
Liste der Anhänge anzeigen (Anzahl: 1)
GetMonitorCapabilities function
Retrieves the configuration capabilities of a monitor. Call this function to find out which high-level monitor configuration functions are supported by the monitor. Requirements: Minimum supported client: Windows Vista ![]() WmiSetBrightness method of the WmiMonitorBrightnessMethods class ![]()
Delphi-Quellcode:
Crosspost:
program SETBright;
{$APPTYPE CONSOLE} uses SysUtils, ActiveX, Variants, ComObj; var dark : Integer; darkStr : String; procedure SetBrightness(Timeout : Integer; Brightness : Byte); var FSWbemLocator : OLEVariant; FWMIService : OLEVariant; FWbemObjectSet: OLEVariant; FWbemObject : OLEVariant; oEnum : IEnumvariant; iValue : LongWord; begin; FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer('localhost', 'root\WMI', '', ''); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM WmiMonitorBrightnessMethods Where Active=True','WQL',$00000020); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; while oEnum.Next(1, FWbemObject, iValue) = 0 do begin FWbemObject.WmiSetBrightness(Timeout, Brightness); FWbemObject:=Unassigned; end; end; begin dark:=40; //default if ParamCount>0 then begin darkStr:= ParamStr(1); dark:= StrToInt(darkStr); end; try CoInitialize(nil); try SetBrightness(5, dark); finally CoUninitialize; end; except on E:EOleException do Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode])); on E:Exception do Writeln(E.Classname, ':', E.Message); end; Writeln('Press Enter to exit');// delete it Readln; // delete it end. (* Batch file: setbright.bat setbright <0 - 100> Example: setbright 40 *) ![]() Im Anhang: Source, EXE, Batchfiles |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:01 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz