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 http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx WmiSetBrightness method of the WmiMonitorBrightnessMethods class http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
Delphi-Quellcode:
Crosspost: http://www.entwickler-ecke.de/viewto...=680567#680567
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 00:12 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz