Programlama yapalım ve Öğrenelim. - Delphi Eğitim89
  Ana Sayfa
  .NET Eğitim Notları
  Visual C# .NET Örnek Kodları
  VisualBasic.NET Örnek Kodları
  J# Örnekleri
  ASP.NET Örnek Kodları
  Delphi Eğitim
  => Delphi Eğitim1
  => Delphi Eğitim2
  => Delphi Eğitim3
  => Delphi Eğitim4
  => Delphi Eğitim5
  => Delphi Eğitim6
  => Delphi Eğitim7
  => Delphi Eğitim8
  => Delphi Eğitim9
  => Delphi Eğitim10
  => Delphi Eğitim11
  => Delphi Eğitim13
  => Delphi Eğitim14
  => Delphi Eğitim15
  => Delphi Eğitim16
  => Delphi Eğitim17
  => Delphi Eğitim18
  => Delphi Eğitim19
  => Delphi Eğitim20
  => Delphi Eğitim21
  => Delphi Eğitim22
  => Delphi Eğitim23
  => Delphi Eğitim24
  => Delphi Eğitim25
  => Delphi Eğitim26
  => Delphi Eğitim27
  => Delphi Eğitim28
  => Delphi Eğitim29
  => Delphi Eğitim30
  => Delphi Eğtim31
  => Delphi Eğitim32
  => Delphi Eğitim33
  => Delphi Eğitim34
  => Delphi Eğitim35
  => Delphi Eğitim36
  => Delphi Eğitim37
  => Delphi Eğitim38
  => Delphi Eğitim39
  => Delphi Eğitim40
  => Delphi Eğitim41
  => Delphi Eğitim42
  => Delphi Eğitim43
  => Delphi Eğitim44
  => Delphi Eğitim45
  => Delphi Eğitim46
  => Delphi Eğitim47
  => Delphi Eğitim48
  => Delphi Eğitim49
  => Delphi Eğitim50
  => Delphi Eğitim51
  => Delphi Eğitim52
  => Delphi Eğitim53
  => Delphi Eğitim54
  => Delphi Eğitim55
  => Delphi Eğitim56
  => Delphi Eğitim57
  => Delphi Eğitim58
  => Delphi Eğitim59
  => Delphi Eğitim60
  => Delphi Eğitim61
  => Delphi Eğitim62
  => Delphi Eğitim63
  => Delphi Eğitim64
  => Delphi Eğitim65
  => Delphi Eğitim66
  => Delphi Eğitim67
  => Delphi Eğitim68
  => Delphi Eğitim69
  => Delphi Eğitim70
  => Delphi Eğitim71
  => Delphi Eğitim72
  => Delphi Eğitim73
  => Delphi Eğitim74
  => Delphi Eğitim75
  => Delphi Eğitim76
  => Delphi Eğitim77
  => Delphi Eğitim78
  => Delphi Eğitim79
  => Delphi Eğitim80
  => Delphi Eğitim81
  => Delphi Eğitim82
  => Delphi Eğitim83
  => Delphi Eğitim84
  => Delphi Eğitim85
  => Delphi Eğitim86
  => Delphi Eğitim87
  => Delphi Eğitim88
  => Delphi Eğitim89
  => Delphi Eğitim90
  => Delphi Eğitim91
  => Delphi Eğitim92
  => Delphi Eğitim93
  => Delphi Eğitim94
  => Delphi Eğitim95
  => Delphi Eğitim96
  => Delphi Eğitim97
  => Delphi Eğitim98
  => Delphi Eğitim99
  => Delphi Eğitim100
  => Delphi Eğitim101
  => Delphi Eğitim102
  => Delphi Eğitim103
  => Delphi Eğitim104
  => Delphi Eğitim105
  => Delphi Eğitim106
  => Delphi Eğitim107
  => Delphi Eğitim108
  => Delphi Eğitim109
  => Delphi Eğitim110
  => Delphi Eğitim111
  => Delphi Eğitim112
  => Delphi Eğitim113
  => Delphi Eğitim114
  => Delphi Eğitim115
  => Delphi Eğitim116
  => Delphi Eğitim117
  => Delphi Eğitim118
  => Delphi Eğitim119
  => Delphi Eğitim120
  => Delphi Eğitim121
  => Delphi Eğitim122
  => Delphi Eğitim123
  => Delphi Eğitim124
  => Delphi Eğitim125
  => Delphi Eğitim126
  => Delphi Eğitim127
  => Delphi Eğitim128
  => Delphi Eğitim129
  => Delphi Eğitim130
  => Delphi Eğitim131
  => Delphi Eğitim132
  => Delphi Eğitim133
  => Delphi Eğitim134
  => Delphi Eğitim135
  => Delphi Eğitim136
  => Delphi Eğitim137
  => Delphi Eğitim138
  => Delphi Eğitim139
  => Delphi Eğitim140
  => Delphi Eğitim141
  => Delphi Eğitim142
  => Delphi Eğitim143
  => Delphi Eğitim144
  => Delphi Eğitim145
  => Delphi Eğitim146
  => Delphi eğitim147
  => Delphi Eğitim148
  => Delphi Eğitim149
  => Delphi Eğitim150
  => Delphi Eğitim151
  => Delphi Eğitim152
  => Delphi Eğitim153
  => Delphi Eğitim154
  => Delphi Eğitim155
  => Delphi Eğitim156
  => Delphi Eğitim157
  => Delphi Eğitim158
  => Delphi Eğitim159
  => Delphi Eğitim160
  => Delphi Eğitim161
  => Delphi Eğitim162
  => Delphi Eğitim164
  => Delphi Eğitim165
  => Delphi Eğitim166
  => Delphi Eğitim167
  => Delphi Eğitim168
  => Delphi Eğitim169
  => Delphi Eğitim170
  => Delphi Eğitim171
  => Delphi Eğitim172
  => Delphi Eğitim173
  => Delphi Eğitim174
  => Delphi Eğitim175
  => Delphi Eğitim176
  => Delphi Eğitim177
  => Delphi Eğitim178
  => Delphi Eğitim179
  => Delphi Eğitim180
  => Delphi Eğitim181
  => Delphi Eğitim182
  => Delphi Eğitim183
  => Delphi Eğitim184
  => Delphi Eğitim185
  => Delphi Eğitim186
  => Delphi Eğitim187
  => Delphi Eğitim188
  => Delphi Eğitim189
  => Delphi Eğitim190
  => Delphi Eğitim191
  => Delphi Eğitim192
  => Delphi Eğitim193
  => Delphi Eğitim194
  => Delphi Eğitim195
  => Delphi Eğitim196
  => Delphi Eğitim197
  => Delphi Eğitim198
  => Delphi Eğitim199
  => Delphi Eğitim200
  => Delphi Eğitim201
  => Delphi Eğitim202
  => Delphi Eğitim203
  => Delphi Eğitim204
  => Delphi Eğitim205
  => Delphi Eğitim206
  => Delphi Eğitim207
  => Delphi Eğitim208
  => Delphi Eğitim209
  => Delphi Eğitim210
  => Delphi Eğitim211
  => Delphi Eğitim212
  => Delphi Eğitim213
  => Delphi Eğitim214
  => Delphi Eğitim215
  => Delphi Eğitim216
  => Delphi Eğitim217
  => Delphi Eğitim218
  => Delphi Eğitim219
  => Delphi Eğitim220
  => Delphi Eğitim221
  => Delphi Eğitim222
  => Delphi Eğitim223
  => Delphi Eğitim224
  => Delphi Eğitim225
  => Delphi Eğitim226
  => Delphi Eğitim227
  => Delphi Eğitim228
  => Delphi Eğitim229
  => Delphi Eğitim230
  => Delphi Eğitim231
  => Delphi Eğitim232
  => Delphi Eğitim233
  => Delphi Eğitim234
  => Delphi Eğitim235
  => Delphi Eğitim236
  => Delphi Eğitim237
  => Delphi Eğitim238
  => Delphi Eğitim239
  => Delphi Eğitim240
  => Delphi Eğitim241
  => Delphi Eğitim242
  İletişim

WMI ILE MAC ADRESINI ALMA

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, ovcbase, ovcfiler, ovcstore, Ping, StdCtrls, Grids,ActiveX, WbemScripting_TLB,

  Menus;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    StringGrid1: TStringGrid;

    ListBox1: TListBox;

    Ping1: TPing;

    OvcIniFileStore1: TOvcIniFileStore;

    SaveDialog1: TSaveDialog;

    MainMenu1: TMainMenu;

    XTDOSYASINAAT1: TMenuItem;

    Memo1: TMemo;

    procedure FormCreate(Sender: TObject);

    procedure Ping1DnsLookupDone(Sender: TObject; Error: Word);

    procedure Ping1EchoReply(Sender, Icmp: TObject; Error: Integer);

    procedure Button1Click(Sender: TObject);

    procedure XTDOSYASINAAT1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

function ADsEnumerateNext(pEnumVariant: IEnumVARIANT; cElements: ULONG;

  var pvar: OleVARIANT; var pcElementsFetched: ULONG): HRESULT; safecall; external 'activeds.dll';

 

 

procedure TForm1.FormCreate(Sender: TObject);

VAR A:INTEGER;

begin

StringGrid1.Cells[0,0]:='IP';

StringGrid1.Cells[1,0]:='MAC';

 

IF FileExists(ExtractFilePath(Application.ExeName)+'IP_LIST.INI') THEN

        BEGIN

        ListBox1.Items.LoadFromFile(ExtractFilePath(Application.ExeName)+'IP_LIST.INI');

 

        FOR A:=0 TO ListBox1.COUNT-1 DO

                IF POS('ROOT',ListBox1.Items[A])>0 THEN

                        BEGIN

                        ListBox1.Items.Delete(A);

                        BREAK;

                        END;

 

 

        StringGrid1.RowCount:=ListBox1.COUNT+1;

        FOR A:=0 TO ListBox1.COUNT-1 DO

                BEGIN

                StringGrid1.Cells[0,A+1]:=ListBox1.Items[A];

                END;

        END;

 

end;

 

procedure TForm1.Ping1DnsLookupDone(Sender: TObject; Error: Word);

begin

   if Error <> 0 then

        Begin

        Application.ProcessMessages;

        StringGrid1.Cells[1,ListBox1.ItemIndex+1]:='BAĞLANTI YOK';

 

        IF ListBox1.ItemIndex<ListBox1.Count-1 THEN

                BEGIN

                ListBox1.ItemIndex:=ListBox1.ItemIndex+1;

                Ping1.DnsLookup(ListBox1.Items[ListBox1.ItemIndex]);

                END;

        EXIT;

        End;

    Ping1.Address := Ping1.DnsResult;

    Ping1.Ping;

end;

 

procedure TForm1.Ping1EchoReply(Sender, Icmp: TObject; Error: Integer);

var

  Service: ISWbemServices;

  Enum: IEnumVARIANT;

 

  varArr: OleVariant;

  lNumElements: ULong;

 

  Method:   ISWbemMethod;

  OutParam:    ISWbemObject;

  SProp1: ISWbemProperty;

  PropValue_1:OleVariant;

 

  Enum_1: IEnumVARIANT;

  SProp: ISWbemProperty;

  Prop: OleVariant;

  PropName: string;

 

  USER:STRING;

begin

if Error = 0 then

        BEGIN

        Application.ProcessMessages;

        StringGrid1.Cells[1,ListBox1.ItemIndex+1]:='BAĞLANTI YOK';

        END

ELSE

        BEGIN

        Application.ProcessMessages;

        StringGrid1.Cells[1,ListBox1.ItemIndex+1]:='BAĞLANTI VAR';

 

 

        /////////////////////////// MAC ADRES AL ////////////////////////////

        Application.ProcessMessages;

        try

 

        SERVICE := CoSWbemLocator.Create.ConnectServer(ListBox1.ITEMS[ListBox1.ItemIndex], 'rootcimv2', '','', '', '', 0, nil);

        ENUM:=SERVICE.ExecQuery('Select MACAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE ', 'WQL',wbemFlagBidirectional, nil)._NewEnum as IEnumVariant;

 

 

        while (Succeeded(ADsEnumerateNext(Enum, 1, varArr, lNumElements))) and (lNumElements > 0) do

            begin

 

            Enum_1 := (IUnknown(varArr) as SWBemObject).Properties_._NewEnum as IEnumVariant;

 

            while (Succeeded(ADsEnumerateNext(Enum_1, 1, VarArr, lNumElements))) and (lNumElements > 0) do

                        begin

                        if Succeeded(IDispatch(varArr).QueryInterface(SWBemProperty, SProp)) and Assigned(SProp) then

                            begin

                                try

 

                                Prop := SProp.Get_Value;

                                StringGrid1.Cells[1,ListBox1.ItemIndex+1]:=Prop;

                             finally

                                END;

 

                             END;

                        END;

                end;

        finally

        end;

        //////////////////////////

        END;

 

IF ListBox1.ItemIndex<ListBox1.Count-1 THEN

        BEGIN

        ListBox1.ItemIndex:=ListBox1.ItemIndex+1;

        Ping1.DnsLookup(ListBox1.Items[ListBox1.ItemIndex]);

        END;

 

end;

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Button1.Enabled:=FALSE;

ListBox1.ItemIndex:=0;

Ping1.DnsLookup(ListBox1.Items[0]);

end;

 

procedure TForm1.XTDOSYASINAAT1Click(Sender: TObject);

var a:integer;

dosya:string;

begin

if SaveDialog1.Execute then

        begin

        memo1.lines.add(

                        StringGrid1.Cells[0,0]+CHR(09)+

                        StringGrid1.Cells[1,0]+CHR(09));

        memo1.lines.add(stringofChar('-',200));

        for a:=1 to StringGrid1.RowCount-1 do

                begin

                memo1.lines.add(

                        StringGrid1.Cells[0,a]+CHR(09)+

                        StringGrid1.Cells[1,a]+CHR(09));

                end;

 

        if copy(savedialog1.filename,length(savedialog1.filename)-3,4)<>'.txt' then

        dosya:=savedialog1.filename+'.txt'

        else dosya:=savedialog1.filename;

        memo1.Lines.SaveToFile(dosya);

        end;

end;

end.

 

Delphi - .....................................

 

WMI ILE MAC ADRESINI ALMA

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, ovcbase, ovcfiler, ovcstore, Ping, StdCtrls, Grids,ActiveX, WbemScripting_TLB,

  Menus;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    StringGrid1: TStringGrid;

    ListBox1: TListBox;

    Ping1: TPing;

    OvcIniFileStore1: TOvcIniFileStore;

    SaveDialog1: TSaveDialog;

    MainMenu1: TMainMenu;

    XTDOSYASINAAT1: TMenuItem;

    Memo1: TMemo;

    procedure FormCreate(Sender: TObject);

    procedure Ping1DnsLookupDone(Sender: TObject; Error: Word);

    procedure Ping1EchoReply(Sender, Icmp: TObject; Error: Integer);

    procedure Button1Click(Sender: TObject);

    procedure XTDOSYASINAAT1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

function ADsEnumerateNext(pEnumVariant: IEnumVARIANT; cElements: ULONG;

  var pvar: OleVARIANT; var pcElementsFetched: ULONG): HRESULT; safecall; external 'activeds.dll';

 

 

procedure TForm1.FormCreate(Sender: TObject);

VAR A:INTEGER;

begin

StringGrid1.Cells[0,0]:='IP';

StringGrid1.Cells[1,0]:='MAC';

 

IF FileExists(ExtractFilePath(Application.ExeName)+'IP_LIST.INI') THEN

        BEGIN

        ListBox1.Items.LoadFromFile(ExtractFilePath(Application.ExeName)+'IP_LIST.INI');

 

        FOR A:=0 TO ListBox1.COUNT-1 DO

                IF POS('ROOT',ListBox1.Items[A])>0 THEN

                        BEGIN

                        ListBox1.Items.Delete(A);

                        BREAK;

                        END;

 

 

        StringGrid1.RowCount:=ListBox1.COUNT+1;

        FOR A:=0 TO ListBox1.COUNT-1 DO

                BEGIN

                StringGrid1.Cells[0,A+1]:=ListBox1.Items[A];

                END;

        END;

 

end;

 

procedure TForm1.Ping1DnsLookupDone(Sender: TObject; Error: Word);

begin

   if Error <> 0 then

        Begin

        Application.ProcessMessages;

        StringGrid1.Cells[1,ListBox1.ItemIndex+1]:='BAĞLANTI YOK';

 

        IF ListBox1.ItemIndex<ListBox1.Count-1 THEN

                BEGIN

                ListBox1.ItemIndex:=ListBox1.ItemIndex+1;

                Ping1.DnsLookup(ListBox1.Items[ListBox1.ItemIndex]);

                END;

        EXIT;

        End;

    Ping1.Address := Ping1.DnsResult;

    Ping1.Ping;

end;

 

procedure TForm1.Ping1EchoReply(Sender, Icmp: TObject; Error: Integer);

var

  Service: ISWbemServices;

  Enum: IEnumVARIANT;

 

  varArr: OleVariant;

  lNumElements: ULong;

 

  Method:   ISWbemMethod;

  OutParam:    ISWbemObject;

  SProp1: ISWbemProperty;

  PropValue_1:OleVariant;

 

  Enum_1: IEnumVARIANT;

  SProp: ISWbemProperty;

  Prop: OleVariant;

  PropName: string;

 

  USER:STRING;

begin

if Error = 0 then

        BEGIN

        Application.ProcessMessages;

        StringGrid1.Cells[1,ListBox1.ItemIndex+1]:='BAĞLANTI YOK';

        END

ELSE

        BEGIN

        Application.ProcessMessages;

        StringGrid1.Cells[1,ListBox1.ItemIndex+1]:='BAĞLANTI VAR';

 

 

        /////////////////////////// MAC ADRES AL ////////////////////////////

        Application.ProcessMessages;

        try

 

        SERVICE := CoSWbemLocator.Create.ConnectServer(ListBox1.ITEMS[ListBox1.ItemIndex], 'rootcimv2', '','', '', '', 0, nil);

        ENUM:=SERVICE.ExecQuery('Select MACAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE ', 'WQL',wbemFlagBidirectional, nil)._NewEnum as IEnumVariant;

 

 

        while (Succeeded(ADsEnumerateNext(Enum, 1, varArr, lNumElements))) and (lNumElements > 0) do

            begin

 

            Enum_1 := (IUnknown(varArr) as SWBemObject).Properties_._NewEnum as IEnumVariant;

 

            while (Succeeded(ADsEnumerateNext(Enum_1, 1, VarArr, lNumElements))) and (lNumElements > 0) do

                        begin

                        if Succeeded(IDispatch(varArr).QueryInterface(SWBemProperty, SProp)) and Assigned(SProp) then

                            begin

                                try

 

                                Prop := SProp.Get_Value;

                                StringGrid1.Cells[1,ListBox1.ItemIndex+1]:=Prop;

                             finally

                                END;

 

                             END;

                        END;

                end;

        finally

        end;

        //////////////////////////

        END;

 

IF ListBox1.ItemIndex<ListBox1.Count-1 THEN

        BEGIN

        ListBox1.ItemIndex:=ListBox1.ItemIndex+1;

        Ping1.DnsLookup(ListBox1.Items[ListBox1.ItemIndex]);

        END;

 

end;

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Button1.Enabled:=FALSE;

ListBox1.ItemIndex:=0;

Ping1.DnsLookup(ListBox1.Items[0]);

end;

 

procedure TForm1.XTDOSYASINAAT1Click(Sender: TObject);

var a:integer;

dosya:string;

begin

if SaveDialog1.Execute then

        begin

        memo1.lines.add(

                        StringGrid1.Cells[0,0]+CHR(09)+

                        StringGrid1.Cells[1,0]+CHR(09));

        memo1.lines.add(stringofChar('-',200));

        for a:=1 to StringGrid1.RowCount-1 do

                begin

                memo1.lines.add(

                        StringGrid1.Cells[0,a]+CHR(09)+

                        StringGrid1.Cells[1,a]+CHR(09));

                end;

 

        if copy(savedialog1.filename,length(savedialog1.filename)-3,4)<>'.txt' then

        dosya:=savedialog1.filename+'.txt'

        else dosya:=savedialog1.filename;

        memo1.Lines.SaveToFile(dosya);

        end;

end;

end.

 

Delphi - .....................................

 

WM ILE PROCESSLER HAKKINDA BILGI ALMA

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    Memo1: TMemo;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

uses

  ActiveX, WbemScripting_TLB;

 

{$R *.dfm}

 

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

 

 

PROP:=Process.Security_.

 

  Form1.Memo1.Lines.Add('+ WMI Path: ' + Process.Path_.Path);

  Form1.Memo1.Lines.Add('----: ' + Process. Path_.Locale);

 

  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));

        PropType := VarAsType(VarType(Prop),varString);

        PropValue := VarToStr(Prop);

        Form1.Memo1.Lines.Add('  + ' + PropName + '[' + PropType + '] = ' + PropValue);

      except

        on E: Exception do

        begin

          // WriteLn(ErrOutput, PropName, ': ', E.Message);

        end;

      end;

    end;

  end;

end;

 

 

 

 

procedure TForm1.Button1Click(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

    Memo1.Lines.BeginUpdate;

    Enum := CoSWbemLocator.Create.ConnectServer(Server, 'rootcimv2', '',

      '', '', '', 0, nil).ExecQuery('Select * from Win32_Process', '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

    Memo1.Lines.EndUpdate;

  end;

 

end;

 

end.

 

Delphi - .....................................

 

WM ILE PROCESSLER HAKKINDA BILGI ALMA

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    Memo1: TMemo;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

uses

  ActiveX, WbemScripting_TLB;

 

{$R *.dfm}

 

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

 

 

PROP:=Process.Security_.

 

  Form1.Memo1.Lines.Add('+ WMI Path: ' + Process.Path_.Path);

  Form1.Memo1.Lines.Add('----: ' + Process. Path_.Locale);

 

  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));

        PropType := VarAsType(VarType(Prop),varString);

        PropValue := VarToStr(Prop);

        Form1.Memo1.Lines.Add('  + ' + PropName + '[' + PropType + '] = ' + PropValue);

      except

        on E: Exception do

        begin

          // WriteLn(ErrOutput, PropName, ': ', E.Message);

        end;

      end;

    end;

  end;

end;

 

 

 

 

procedure TForm1.Button1Click(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

    Memo1.Lines.BeginUpdate;

    Enum := CoSWbemLocator.Create.ConnectServer(Server, 'rootcimv2', '',

      '', '', '', 0, nil).ExecQuery('Select * from Win32_Process', '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

    Memo1.Lines.EndUpdate;

  end;

 

end;

 

end.

 

Delphi - .....................................

 

WMI ILE PROGRAM CALISTIR (CREATE PROCESS)

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls,WbemScripting_TLB, OleServer, ActiveX;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    Edit1: TEdit;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

  SWbemLocator1: TSWbemLocator;

  Service: ISWbemServices;

  InParam, OutParam, SObject, Process:    ISWbemObject;

  Method:   ISWbemMethod;

  SProp1, SProp2, MyProperty: ISWbemProperty;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.Button1Click(Sender: TObject);

var

  PropValue: OleVariant;

begin

  Service:= CoSWbemLocator.CREATE.ConnectServer(EDIT1.TEXT, 'rootcimv2', '', '', '',   '', 0, nil);

  // ??. ??????? 1

  Service.Security_.Set_ImpersonationLevel(wbemImpersonationLevelImpersonate);

  Process:= Service.Get('Win32_Process', 0, nil);

 

  Method:= Process.Methods_.Item('Create', 0);

 

  InParam:= Method.InParameters.SpawnInstance_(0);

 

  MyProperty:= InParam.Properties_.Add('CommandLine', wbemCimtypeString, False, 0);

 

  PropValue:= 'GPUPDATE /FORCE';

  MyProperty.Set_Value(PropValue);

 

  OutParam:= Process.ExecMethod_('Create', InParam, 0, nil);

 

  SProp1:= outParam.Properties_.Item('ReturnValue', 0);

 

   if SProp1.Get_Value = 0 then

  begin

    SProp2:= outParam.Properties_.Item('ProcessID', 0);

    Button1.Enabled:= False;

    sleep(300);

    SetForegroundWindow(Form1.Handle);

  end

  else

    MessageBox(0, PChar('?? ???? ?????? ???????.'), PChar(Form1.Caption), MB_OK);

 

end;

 

end.

 

procedure TForm1.Button4Click(Sender: TObject);

begin

 

end;

 

Delphi - .....................................

 

WMI ILE PROGRAM CALISTIR (CREATE PROCESS)

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls,WbemScripting_TLB, OleServer, ActiveX;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    Edit1: TEdit;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

  SWbemLocator1: TSWbemLocator;

  Service: ISWbemServices;

  InParam, OutParam, SObject, Process:    ISWbemObject;

  Method:   ISWbemMethod;

  SProp1, SProp2, MyProperty: ISWbemProperty;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.Button1Click(Sender: TObject);

var

  PropValue: OleVariant;

begin

  Service:= CoSWbemLocator.CREATE.ConnectServer(EDIT1.TEXT, 'rootcimv2', '', '', '',   '', 0, nil);

  // ??. ??????? 1

  Service.Security_.Set_ImpersonationLevel(wbemImpersonationLevelImpersonate);

  Process:= Service.Get('Win32_Process', 0, nil);

 

  Method:= Process.Methods_.Item('Create', 0);

 

  InParam:= Method.InParameters.SpawnInstance_(0);

 

  MyProperty:= InParam.Properties_.Add('CommandLine', wbemCimtypeString, False, 0);

 

  PropValue:= 'GPUPDATE /FORCE';

  MyProperty.Set_Value(PropValue);

 

  OutParam:= Process.ExecMethod_('Create', InParam, 0, nil);

 

  SProp1:= outParam.Properties_.Item('ReturnValue', 0);

 

   if SProp1.Get_Value = 0 then

  begin

    SProp2:= outParam.Properties_.Item('ProcessID', 0);

    Button1.Enabled:= False;

    sleep(300);

    SetForegroundWindow(Form1.Handle);

  end

  else

    MessageBox(0, PChar('?? ???? ?????? ???????.'), PChar(Form1.Caption), MB_OK);

 

end;

 

end.

 

procedure TForm1.Button4Click(Sender: TObject);

begin

 

end;

 

Delphi - .....................................

 

WMI ILE REMOTE BILGISAYARDAKI PROCESS LISTESINI ALMA

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    Memo1: TMemo;

    Edit1: TEdit;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

uses

  ActiveX, WbemScripting_TLB;

 

{$R *.dfm}

 

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

  //Form1.Memo1.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));

        PropType := VarAsType(VarType(Prop),varString);

        PropValue := VarToStr(Prop);

        SProp.

 

        IF PropName='Caption' THEN

        Form1.Memo1.Lines.Add(PropValue+'---');

        //Form1.Memo1.Lines.Add('  + ' + PropName + '[' + PropType + '] = ' + PropValue);

        IF PropName='ExecutablePath' THEN

        Form1.Memo1.Lines[Form1.Memo1.Lines.Count-1]:=Form1.Memo1.Lines[Form1.Memo1.Lines.Count-1]+' - ' +PropValue;

 

      except

        on E: Exception do

        begin

          // WriteLn(ErrOutput, PropName, ': ', E.Message);

        end;

      end;

    end;

  end;

end;

 

procedure TForm1.Button1Click(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 := EDIT1.TEXT;

    ASize  := SizeOf(AName) - 1;

    IF Server='' THEN

    if GetComputerName(@AName, ASize) then Server := AName;

  end

  else

  begin

    Server := ParamStr(1);

  end;

  try

    Memo1.Lines.BeginUpdate;

    Enum := CoSWbemLocator.Create.ConnectServer(Server, 'rootcimv2', '',

      '', '', '', 0, nil).ExecQuery('Select * from Win32_Process', '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

    Memo1.Lines.EndUpdate;

  end;

 

end;

 

end.

 

Delphi - .....................................

 

WMI ILE REMOTE BILGISAYARDAKI PROCESS LISTESINI ALMA

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    Memo1: TMemo;

    Edit1: TEdit;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

uses

  ActiveX, WbemScripting_TLB;

 

{$R *.dfm}

 

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

  //Form1.Memo1.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));

        PropType := VarAsType(VarType(Prop),varString);

        PropValue := VarToStr(Prop);

        SProp.

 

        IF PropName='Caption' THEN

        Form1.Memo1.Lines.Add(PropValue+'---');

        //Form1.Memo1.Lines.Add('  + ' + PropName + '[' + PropType + '] = ' + PropValue);

        IF PropName='ExecutablePath' THEN

        Form1.Memo1.Lines[Form1.Memo1.Lines.Count-1]:=Form1.Memo1.Lines[Form1.Memo1.Lines.Count-1]+' - ' +PropValue;

 

      except

        on E: Exception do

        begin

          // WriteLn(ErrOutput, PropName, ': ', E.Message);

        end;

      end;

    end;

  end;

end;

 

procedure TForm1.Button1Click(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 := EDIT1.TEXT;

    ASize  := SizeOf(AName) - 1;

    IF Server='' THEN

    if GetComputerName(@AName, ASize) then Server := AName;

  end

  else

  begin

    Server := ParamStr(1);

  end;

  try

    Memo1.Lines.BeginUpdate;

    Enum := CoSWbemLocator.Create.ConnectServer(Server, 'rootcimv2', '',

      '', '', '', 0, nil).ExecQuery('Select * from Win32_Process', '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

    Memo1.Lines.EndUpdate;

  end;

 

end;

 

end.

 

Delphi - .....................................

 

WMI ILE REMOTE BILGISAYARDAKI PROCESS VE OWNER LISTESINI ALMA

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls,ActiveX, WbemScripting_TLB, Grids, Menus;

 

type

  TForm1 = class(TForm)

    StringGrid1: TStringGrid;

    MainMenu1: TMainMenu;

    XTDOSYASINAAT1: TMenuItem;

    SaveDialog1: TSaveDialog;

    Memo1: TMemo;

    PopupMenu1: TPopupMenu;

    PROCESSKAPAT1: TMenuItem;

    YENLE1: TMenuItem;

 

procedure PROCESS_AL(IP_AL:STRING);

 

    procedure FormCreate(Sender: TObject);

    procedure XTDOSYASINAAT1Click(Sender: TObject);

    procedure PROCESSKAPAT1Click(Sender: TObject);

    procedure YENLE1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

  IP:STRING;

 

  Service: ISWbemServices;

  Enum: IEnumVARIANT;

  SAYDIR:INTEGER;

 

implementation

 

{$R *.dfm}

 

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;

 

  SObject:    ISWbemObject;

  Method:   ISWbemMethod;

  OutParam:    ISWbemObject;

  SProp1: ISWbemProperty;

  PropValue_1:OleVariant;

begin

  SAYDIR:=SAYDIR+1;

  Form1.StringGrid1.RowCount:=Form1.StringGrid1.RowCount+1;

 

  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 := VarAsType(VarType(Prop),varString);

        PropValue := VarToStr(Prop);

 

 

        IF PropName='Caption' THEN

                Form1.StringGrid1.Cells[0,SAYDIR]:=PropValue;

        IF PropName='Handle' THEN

                Form1.StringGrid1.Cells[1,SAYDIR]:=PropValue;

        IF PropName='ExecutablePath' THEN

                Form1.StringGrid1.Cells[2,SAYDIR]:=PropValue;

 

        IF PropName='Handle' THEN

                BEGIN

                SObject:=SERVICE.Get('Win32_Process.Handle="' +  WideString(PropValue) + '"', 0, nil);

                IF SObject<>NIL THEN

                        BEGIN

                        Method:= SOBject.Methods_.Item('GETOWNER', 0);

                        OutParam:= SObject.ExecMethod_('GETOWNER', outParam, 0, nil);

                        SProp1:= outParam.Properties_.Item('USER', 0);

                        PropValue_1:=SProp1.Get_Value;

                        Form1.StringGrid1.Cells[3,SAYDIR]:=VarToStr(PropValue_1);

                        END;

 

               END;

 

      except

        on E: Exception do

        begin

        end;

      end;

    end;

  end;

end;

 

procedure TForm1.PROCESS_AL(IP_AL:STRING);

var

  varArr: OleVariant;

  lNumElements: ULong;

  AName: array[0..255] of Char;

  ASize: DWORD;

begin

SAYDIR:=0;

 

  try

    SERVICE := CoSWbemLocator.Create.ConnectServer(IP, 'rootcimv2', '','', '', '', 0, nil);

     ENUM:=SERVICE.ExecQuery('Select * from Win32_Process', '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

  end;

 

end;

 

 

procedure TForm1.FormCreate(Sender: TObject);

begin

StringGrid1.Cells[0,0]:='PROCESS';

StringGrid1.Cells[1,0]:='PID';

StringGrid1.Cells[2,0]:='DOSYA YOLU';

StringGrid1.Cells[3,0]:='KULLANICI';

 

 

IF ParamCount>0 THEN

        IP:=ParamStr(1)

ELSE

        IP:='.';

 

StringGrid1.ColWidths[1]:=40;

PROCESS_AL(IP);

end;

 

procedure TForm1.XTDOSYASINAAT1Click(Sender: TObject);

var a:integer;

dosya:string;

begin

if SaveDialog1.Execute then

        begin

        memo1.lines.add(

                        StringGrid1.Cells[0,0]+CHR(09)+

                        StringGrid1.Cells[1,0]+CHR(09)+

                        StringGrid1.Cells[2,0]+CHR(09)+

                        StringGrid1.Cells[3,0]+CHR(09));

        memo1.lines.add(stringofChar('-',200));

        for a:=1 to StringGrid1.RowCount-1 do

                begin

                memo1.lines.add(

                        StringGrid1.Cells[0,a]+CHR(09)+

                        StringGrid1.Cells[1,a]+CHR(09)+

                        StringGrid1.Cells[2,a]+CHR(09)+

                        StringGrid1.Cells[3,a]+CHR(09));

                end;

 

        if copy(savedialog1.filename,length(savedialog1.filename)-3,4)<>'.txt' then

        dosya:=savedialog1.filename+'.txt'

        else dosya:=savedialog1.filename;

        memo1.Lines.SaveToFile(dosya);

        end;

end;

 

procedure TForm1.PROCESSKAPAT1Click(Sender: TObject);

VAR A:INTEGER;

begin

IF StringGrid1.Cells[0,StringGrid1.Row]='' THEN EXIT;

IF StringGrid1.Cells[1,StringGrid1.Row]='' THEN EXIT;

 

IF IP='' THEN

        WinExec(PCHAR('TASKKILL /PID '+ StringGrid1.Cells[1,StringGrid1.Row]),SW_SHOW);

IF IP<>'' THEN

        WinExec(PCHAR('TASKKILL /S '+IP+' /PID '+ StringGrid1.Cells[1,StringGrid1.Row]),SW_SHOW);

 

FOR A:=1 TO StringGrid1.RowCount-1 DO

        BEGIN

        StringGrid1.Cells[0,A]:='';

        StringGrid1.Cells[1,A]:='';

        StringGrid1.Cells[2,A]:='';

        StringGrid1.Cells[3,A]:='';

        END;

 

Form1.StringGrid1.RowCount:=2;

PROCESS_AL(IP);

end;

 

procedure TForm1.YENLE1Click(Sender: TObject);

VAR A:INTEGER;

begin

FOR A:=1 TO StringGrid1.RowCount-1 DO

        BEGIN

        StringGrid1.Cells[0,A]:='';

        StringGrid1.Cells[1,A]:='';

        StringGrid1.Cells[2,A]:='';

        StringGrid1.Cells[3,A]:='';

        END;

 

StringGrid1.RowCount:=2;

PROCESS_AL(IP);

end;

 

end.

 

Delphi - .....................................

 

WMI ILE REMOTE BILGISAYARDAKI PROCESS VE OWNER LISTESINI ALMA

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls,ActiveX, WbemScripting_TLB, Grids, Menus;

 

type

  TForm1 = class(TForm)

    StringGrid1: TStringGrid;

    MainMenu1: TMainMenu;

    XTDOSYASINAAT1: TMenuItem;

    SaveDialog1: TSaveDialog;

    Memo1: TMemo;

    PopupMenu1: TPopupMenu;

    PROCESSKAPAT1: TMenuItem;

    YENLE1: TMenuItem;

 

procedure PROCESS_AL(IP_AL:STRING);

 

    procedure FormCreate(Sender: TObject);

    procedure XTDOSYASINAAT1Click(Sender: TObject);

    procedure PROCESSKAPAT1Click(Sender: TObject);

    procedure YENLE1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

  IP:STRING;

 

  Service: ISWbemServices;

  Enum: IEnumVARIANT;

  SAYDIR:INTEGER;

 

implementation

 

{$R *.dfm}

 

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;

 

  SObject:    ISWbemObject;

  Method:   ISWbemMethod;

  OutParam:    ISWbemObject;

  SProp1: ISWbemProperty;

  PropValue_1:OleVariant;

begin

  SAYDIR:=SAYDIR+1;

  Form1.StringGrid1.RowCount:=Form1.StringGrid1.RowCount+1;

 

  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 := VarAsType(VarType(Prop),varString);

        PropValue := VarToStr(Prop);

 

 

        IF PropName='Caption' THEN

                Form1.StringGrid1.Cells[0,SAYDIR]:=PropValue;

        IF PropName='Handle' THEN

                Form1.StringGrid1.Cells[1,SAYDIR]:=PropValue;

        IF PropName='ExecutablePath' THEN

                Form1.StringGrid1.Cells[2,SAYDIR]:=PropValue;

 

        IF PropName='Handle' THEN

                BEGIN

                SObject:=SERVICE.Get('Win32_Process.Handle="' +  WideString(PropValue) + '"', 0, nil);

                IF SObject<>NIL THEN

                        BEGIN

                        Method:= SOBject.Methods_.Item('GETOWNER', 0);

                        OutParam:= SObject.ExecMethod_('GETOWNER', outParam, 0, nil);

                        SProp1:= outParam.Properties_.Item('USER', 0);

                        PropValue_1:=SProp1.Get_Value;

                        Form1.StringGrid1.Cells[3,SAYDIR]:=VarToStr(PropValue_1);

                        END;

 

               END;

 

      except

        on E: Exception do

        begin

        end;

      end;

    end;

  end;

end;

 

procedure TForm1.PROCESS_AL(IP_AL:STRING);

var

  varArr: OleVariant;

  lNumElements: ULong;

  AName: array[0..255] of Char;

  ASize: DWORD;

begin

SAYDIR:=0;

 

  try

    SERVICE := CoSWbemLocator.Create.ConnectServer(IP, 'rootcimv2', '','', '', '', 0, nil);

     ENUM:=SERVICE.ExecQuery('Select * from Win32_Process', '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

  end;

 

end;

 

 

procedure TForm1.FormCreate(Sender: TObject);

begin

StringGrid1.Cells[0,0]:='PROCESS';

StringGrid1.Cells[1,0]:='PID';

StringGrid1.Cells[2,0]:='DOSYA YOLU';

StringGrid1.Cells[3,0]:='KULLANICI';

 

 

IF ParamCount>0 THEN

        IP:=ParamStr(1)

ELSE

        IP:='.';

 

StringGrid1.ColWidths[1]:=40;

PROCESS_AL(IP);

end;

 

procedure TForm1.XTDOSYASINAAT1Click(Sender: TObject);

var a:integer;

dosya:string;

begin

if SaveDialog1.Execute then

        begin

        memo1.lines.add(

                        StringGrid1.Cells[0,0]+CHR(09)+

                        StringGrid1.Cells[1,0]+CHR(09)+

                        StringGrid1.Cells[2,0]+CHR(09)+

                        StringGrid1.Cells[3,0]+CHR(09));

        memo1.lines.add(stringofChar('-',200));

        for a:=1 to StringGrid1.RowCount-1 do

                begin

                memo1.lines.add(

                        StringGrid1.Cells[0,a]+CHR(09)+

                        StringGrid1.Cells[1,a]+CHR(09)+

                        StringGrid1.Cells[2,a]+CHR(09)+

                        StringGrid1.Cells[3,a]+CHR(09));

                end;

 

        if copy(savedialog1.filename,length(savedialog1.filename)-3,4)<>'.txt' then

        dosya:=savedialog1.filename+'.txt'

        else dosya:=savedialog1.filename;

        memo1.Lines.SaveToFile(dosya);

        end;

end;

 

procedure TForm1.PROCESSKAPAT1Click(Sender: TObject);

VAR A:INTEGER;

begin

IF StringGrid1.Cells[0,StringGrid1.Row]='' THEN EXIT;

IF StringGrid1.Cells[1,StringGrid1.Row]='' THEN EXIT;

 

IF IP='' THEN

        WinExec(PCHAR('TASKKILL /PID '+ StringGrid1.Cells[1,StringGrid1.Row]),SW_SHOW);

IF IP<>'' THEN

        WinExec(PCHAR('TASKKILL /S '+IP+' /PID '+ StringGrid1.Cells[1,StringGrid1.Row]),SW_SHOW);

 

FOR A:=1 TO StringGrid1.RowCount-1 DO

        BEGIN

        StringGrid1.Cells[0,A]:='';

        StringGrid1.Cells[1,A]:='';

        StringGrid1.Cells[2,A]:='';

        StringGrid1.Cells[3,A]:='';

        END;

 

Form1.StringGrid1.RowCount:=2;

PROCESS_AL(IP);

end;

 

procedure TForm1.YENLE1Click(Sender: TObject);

VAR A:INTEGER;

begin

FOR A:=1 TO StringGrid1.RowCount-1 DO

        BEGIN

        StringGrid1.Cells[0,A]:='';

        StringGrid1.Cells[1,A]:='';

        StringGrid1.Cells[2,A]:='';

        StringGrid1.Cells[3,A]:='';

        END;

 

StringGrid1.RowCount:=2;

PROCESS_AL(IP);

end;

 

end.

 

Delphi - .....................................

Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol