1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
implementation
{$R *.dfm}
uses
ActiveX, WbemScripting_TLB;
function ADsEnumerateNext(pEnumVariant: IEnumVARIANT; cElements: ULONG;
var pvar: OleVARIANT; var pcElementsFetched: ULONG): HRESULT; safecall; external 'activeds.dll';
procedure DumpWMI_Process(Process: SWBemObject);
var
Enum: IEnumVARIANT;
varArr: OleVariant;
lNumElements: ULong;
SProp: ISWbemProperty;
Prop: OleVariant;
PropName: string;
PropType: string;
PropValue: string;
begin
FResolution.MVideoController.Lines.Add('+ WMI Path: ' + Process.Path_.Path);
Enum := Process.Properties_._NewEnum as IEnumVariant;
while (Succeeded(ADsEnumerateNext(Enum, 1, VarArr, lNumElements))) and
(lNumElements > 0) do
begin
if Succeeded(IDispatch(varArr).QueryInterface(SWBemProperty, SProp)) and
Assigned(SProp) then
begin
try
PropName := SProp.Name;
Prop := SProp.Get_Value;
//PropType := VarTypeAsText(VarType(Prop));
PropValue := VarToStr(Prop);
FResolution.MVideoController.Lines.Add(' + ' + PropName + '[' + PropType + '] = ' + PropValue);
except
on E: Exception do
begin
WriteLn(ErrOutput, PropName, ': ', E.Message);
end;
end;
end;
end;
end;
procedure TFResolution.BResolutionClick(Sender: TObject);
var
Server: string;
Enum: IEnumVARIANT;
varArr: OleVariant;
lNumElements: ULong;
AName: array[0..255] of Char;
ASize: DWORD;
begin
if (ParamCount = 0) then
begin
Server := '';
ASize := SizeOf(AName) - 1;
if GetComputerName(@AName, ASize) then Server := AName;
end
else
begin
Server := ParamStr(1);
end;
try
//'Select * from Win32_videocontroller'
MVideoController.Lines.BeginUpdate;
Enum := CoSWbemLocator.Create.ConnectServer(Server, 'root\cimv2', '',
'', '', '', 0, nil).ExecQuery('Select CurrentHorizontalResolution, CurrentVerticalResolution from Win32_videocontroller', 'WQL',
wbemFlagBidirectional, nil)._NewEnum as IEnumVariant;
while (Succeeded(ADsEnumerateNext(Enum, 1, varArr, lNumElements))) and
(lNumElements > 0) do
begin
DumpWMI_Process(IUnknown(varArr) as SWBemObject);
end;
finally
MVideoController.Lines.EndUpdate;
//Select PelsHeight,PelsWidth from Win32_videocontroller;
//Ligne 73 et position 37 les 4 dernier chiffres
//EdWidth.Text := Copy(MVideoController.Lines[73], Pos('', MVideoController.Lines[73]) +37, Length(MVideoController.Lines[73])); //Width CurrentHorizontalResolution
EdWidth.Text := Copy(MVideoController.Lines[5], Pos('', MVideoController.Lines[5]) +37, Length(MVideoController.Lines[5])); //Width CurrentHorizontalResolution
//Ligne 79 et position 35 les 4 dernier chiffres
//EdHeight.Text := Copy(MVideoController.Lines[79], Pos('',MVideoController.Lines[79]) +35, Length(MVideoController.Lines[79])); //Height CurrentVerticalResolution
EdHeight.Text := Copy(MVideoController.Lines[6], Pos('',MVideoController.Lines[6]) +35, Length(MVideoController.Lines[6])); //Height CurrentVerticalResolution
end;
end;
procedure TFResolution.Button2Click(Sender: TObject);
var
indexdelaligne : integer;
begin
indexdelaligne := SendMessage(MVideoController.Handle, EM_LINEFROMCHAR, MVideoController.SelStart, 0);
ShowMessage(IntToStr(indexdelaligne));
end; |
Partager