Current time: 06-19-2018, 05:51 PM Stay in touch via Twitter Facebook RSS Feed
Ada Baiknya anda baca Peraturan Forum ForNesia Disini Dan Disitu Sebelum Terlambat!
System Registration Forums Mulai Kedepan Sewaktu waktu akan Di Tutup.
Silahkan Dibaca Mengenai Auto Pruning User . Agar tidak ada pertanyaan lagi tentang kehilangan akses forum.



ASK CARA FILTER TAP ADAPTER

06-12-2015 05:10 AM ASK CARA FILTER TAP ADAPTER
#1


mbahsaprol Away
FNS MEMBER
FNS Member
**

Posts: 141
Joined: Mar 2015

Reputation:

FCoin: 11.68ƒc
misi mastah
cara filter tap adapter di delphi gmana ya?
supaya yg tampil cm tap adapter doank
untuk buat tun2sock

mbahsaprol, proud to be a member of ForNesia Family since Mar 2015. dan saya suka Kimcil.
06-14-2015 12:46 AM RE: ASK CARA FILTER TAP ADAPTER
#2


ForNesiaFreak Away
Fake Admin
Lightning Immortals
***

Posts: 1,420
Joined: Jan 2014

Reputation:

FCoin: 28,763.40ƒc

Wing of ForNesiaExtreme StaffTrusted Person
Maaf kalau salah

Spoiler :
Code:
type TIWrapper=class
     public
       prop:ISWbemProperty;
       constructor Create(p:ISWbemProperty);
     end;

constructor TIWrapper.Create(p: ISWbemProperty);
begin
  prop:=p;
end;

procedure clear(Adapters:TStrings);
var i:integer;
begin
  for i:=1 to Adapters.Count do
  begin
    Adapters.Objects[i-1].Free;
    Adapters.Objects[i-1]:=nil;
  end;

  Adapters.Clear;
end;

function getPropValue(sprop:ISWbemProperty):string;
var sValue:string;
    count:integer;
begin
  sValue := '';
  if VarIsNull(SProp.Get_Value) then
    sValue := '<empty>'
  else
  case SProp.CIMType of
    wbemCimtypeSint8, wbemCimtypeUint8, wbemCimtypeSint16, wbemCimtypeUint16,
    wbemCimtypeSint32, wbemCimtypeUint32, wbemCimtypeSint64:
      sValue := IntToStr(SProp.Get_Value);
    wbemCimtypeString, wbemCimtypeUint64:
      if VarIsArray(SProp.Get_Value) then
      begin
        if VarArrayHighBound(SProp.Get_Value, 1) > 0 then
          for Count := 1 to VarArrayHighBound(SProp.Get_Value, 1) do
            sValue := sValue + ' ' + SProp.Get_Value[Count];
      end
    else
      sValue :=  SProp.Get_Value;
    wbemCimtypeDatetime:sValue:=SProp.Get_Value//DateTimeToStr(SProp.Get_Value)
  else
      Exception.Create('Unknown type');
  end; {case}
  result:=sValue;
end;

procedure getAdapters(owner:TComponent; RemoteMachine,RemoteUser,RemotePassword:string; Adapters:TStrings);
var
  Locator: TSWbemLocator;
  SinkClasses: TSWbemSink;

  Services:   ISWbemServices;
  ObjectSet:  ISWbemObjectSet;
  SObject:    ISWbemObject;
  propSet :   ISWbemPropertySet;
  SProp:      ISWbemProperty;
  Enum:       IEnumVariant;
  tempObj:    OleVariant;
  Value:      Cardinal;

  sValue,
  className:     String;
  strQuery:   WideString;
begin
  className:='WIN32_NetworkAdapter';
  clear(adapters);

  Locator:=TSWbemLocator.Create(owner);
  SinkClasses:=TSWbemSink.Create(owner);
  try
    SinkClasses.Cancel;

    if RemoteMachine='' then
      RemoteMachine:='.';// local machine
    Services := Locator.ConnectServer(RemoteMachine, 'root\CIMV2', RemoteUser, RemotePassword, '',
      '', 0, nil);
    try
      ObjectSet := Services.InstancesOf(className, wbemFlagReturnImmediately or wbemQueryFlagShallow, nil);
      Enum :=  (ObjectSet._NewEnum) as IEnumVariant;
      try
        while (Enum.Next(1, tempObj, Value) = S_OK) do
        begin
          SObject := IUnknown(tempObj) as SWBemObject;
          propSet := SObject.Properties_;
          SProp:=propSet.Item('NetConnectionID',0);// caption or systemname
          // now get the value of the property
          sValue:=getPropValue(SProp);
          try
            if sValue<>'<empty>' then
            begin
              sProp:=propSet.Item('NetConnectionStatus',0);
              Adapters.AddObject(sValue,TIWrapper.Create(SProp));
            end;
          finally
            SObject:=nil;
            propSet:=nil;
            SProp:=nil;
          end;
        end; {while Enum}
      finally
        ObjectSet:=nil;
        enum:=nil;
      end;

      strQuery := 'SELECT * FROM __InstanceCreationEvent within 5 WHERE TargetInstance' +
        ' ISA "'+className+'"';
      Services.ExecNotificationQueryAsync(SinkClasses.DefaultInterface, strQuery, 'WQL', 0, nil, nil);
        strQuery := 'SELECT * FROM __InstanceDeletionEvent within 5 WHERE TargetInstance' +
        ' ISA "'+className+'"';
      Services.ExecNotificationQueryAsync(SinkClasses.DefaultInterface, strQuery, 'WQL', 0, nil, nil);
    finally
      Services:=nil;// make sure the references are decreased
    end;
  finally
    Locator.Free;
    SinkClasses.Free;
  end; {try}
end;

// AKHIR CODE MENDAPATKAN INTERFACE NETWORK

function processExists(exeFileName: string): Boolean;
var
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
begin
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  Result := False;
  while Integer(ContinueLoop) <> 0 do
  begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
      UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
      UpperCase(ExeFileName))) then
    begin
      Result := True;
    end;
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);
end;

function KillTask(ExeFileName: string): Integer;
const
  PROCESS_TERMINATE = $0001;
var
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
begin
  Result := 0;
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  while Integer(ContinueLoop) <> 0 do
  begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
      UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
      UpperCase(ExeFileName))) then
      Result := Integer(TerminateProcess(
                        OpenProcess(PROCESS_TERMINATE,
                                    BOOL(0),
                                    FProcessEntry32.th32ProcessID),
                                    0));
     ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  getAdapters(self, '', '', '', fnsadapter.items);
  fnsadapter.ItemIndex := 0;
end;

Need Mod
06-14-2015 01:56 AM RE: ASK CARA FILTER TAP ADAPTER
#3


mbahsaprol Away
FNS MEMBER
FNS Member
**

Posts: 141
Joined: Mar 2015

Reputation:

FCoin: 11.68ƒc
(06-14-2015 12:46 AM)ForNesiaFreak Wrote:  Maaf kalau salah

Spoiler :
Code:
type TIWrapper=class
     public
       prop:ISWbemProperty;
       constructor Create(p:ISWbemProperty);
     end;

constructor TIWrapper.Create(p: ISWbemProperty);
begin
  prop:=p;
end;

procedure clear(Adapters:TStrings);
var i:integer;
begin
  for i:=1 to Adapters.Count do
  begin
    Adapters.Objects[i-1].Free;
    Adapters.Objects[i-1]:=nil;
  end;

  Adapters.Clear;
end;

function getPropValue(sprop:ISWbemProperty):string;
var sValue:string;
    count:integer;
begin
  sValue := '';
  if VarIsNull(SProp.Get_Value) then
    sValue := '<empty>'
  else
  case SProp.CIMType of
    wbemCimtypeSint8, wbemCimtypeUint8, wbemCimtypeSint16, wbemCimtypeUint16,
    wbemCimtypeSint32, wbemCimtypeUint32, wbemCimtypeSint64:
      sValue := IntToStr(SProp.Get_Value);
    wbemCimtypeString, wbemCimtypeUint64:
      if VarIsArray(SProp.Get_Value) then
      begin
        if VarArrayHighBound(SProp.Get_Value, 1) > 0 then
          for Count := 1 to VarArrayHighBound(SProp.Get_Value, 1) do
            sValue := sValue + ' ' + SProp.Get_Value[Count];
      end
    else
      sValue :=  SProp.Get_Value;
    wbemCimtypeDatetime:sValue:=SProp.Get_Value//DateTimeToStr(SProp.Get_Value)
  else
      Exception.Create('Unknown type');
  end; {case}
  result:=sValue;
end;

procedure getAdapters(owner:TComponent; RemoteMachine,RemoteUser,RemotePassword:string; Adapters:TStrings);
var
  Locator: TSWbemLocator;
  SinkClasses: TSWbemSink;

  Services:   ISWbemServices;
  ObjectSet:  ISWbemObjectSet;
  SObject:    ISWbemObject;
  propSet :   ISWbemPropertySet;
  SProp:      ISWbemProperty;
  Enum:       IEnumVariant;
  tempObj:    OleVariant;
  Value:      Cardinal;

  sValue,
  className:     String;
  strQuery:   WideString;
begin
  className:='WIN32_NetworkAdapter';
  clear(adapters);

  Locator:=TSWbemLocator.Create(owner);
  SinkClasses:=TSWbemSink.Create(owner);
  try
    SinkClasses.Cancel;

    if RemoteMachine='' then
      RemoteMachine:='.';// local machine
    Services := Locator.ConnectServer(RemoteMachine, 'root\CIMV2', RemoteUser, RemotePassword, '',
      '', 0, nil);
    try
      ObjectSet := Services.InstancesOf(className, wbemFlagReturnImmediately or wbemQueryFlagShallow, nil);
      Enum :=  (ObjectSet._NewEnum) as IEnumVariant;
      try
        while (Enum.Next(1, tempObj, Value) = S_OK) do
        begin
          SObject := IUnknown(tempObj) as SWBemObject;
          propSet := SObject.Properties_;
          SProp:=propSet.Item('NetConnectionID',0);// caption or systemname
          // now get the value of the property
          sValue:=getPropValue(SProp);
          try
            if sValue<>'<empty>' then
            begin
              sProp:=propSet.Item('NetConnectionStatus',0);
              Adapters.AddObject(sValue,TIWrapper.Create(SProp));
            end;
          finally
            SObject:=nil;
            propSet:=nil;
            SProp:=nil;
          end;
        end; {while Enum}
      finally
        ObjectSet:=nil;
        enum:=nil;
      end;

      strQuery := 'SELECT * FROM __InstanceCreationEvent within 5 WHERE TargetInstance' +
        ' ISA "'+className+'"';
      Services.ExecNotificationQueryAsync(SinkClasses.DefaultInterface, strQuery, 'WQL', 0, nil, nil);
        strQuery := 'SELECT * FROM __InstanceDeletionEvent within 5 WHERE TargetInstance' +
        ' ISA "'+className+'"';
      Services.ExecNotificationQueryAsync(SinkClasses.DefaultInterface, strQuery, 'WQL', 0, nil, nil);
    finally
      Services:=nil;// make sure the references are decreased
    end;
  finally
    Locator.Free;
    SinkClasses.Free;
  end; {try}
end;

// AKHIR CODE MENDAPATKAN INTERFACE NETWORK

function processExists(exeFileName: string): Boolean;
var
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
begin
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  Result := False;
  while Integer(ContinueLoop) <> 0 do
  begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
      UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
      UpperCase(ExeFileName))) then
    begin
      Result := True;
    end;
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);
end;

function KillTask(ExeFileName: string): Integer;
const
  PROCESS_TERMINATE = $0001;
var
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
begin
  Result := 0;
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  while Integer(ContinueLoop) <> 0 do
  begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
      UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
      UpperCase(ExeFileName))) then
      Result := Integer(TerminateProcess(
                        OpenProcess(PROCESS_TERMINATE,
                                    BOOL(0),
                                    FProcessEntry32.th32ProcessID),
                                    0));
     ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  getAdapters(self, '', '', '', fnsadapter.items);
  fnsadapter.ItemIndex := 0;
end;

mksih om dah solved wah

mbahsaprol, proud to be a member of ForNesia Family since Mar 2015. dan saya suka Kimcil.
06-14-2015 02:22 AM RE: ASK CARA FILTER TAP ADAPTER
#4


Arpra99 Away
FNS Police
Super Moderators
*******

Posts: 1,419
Joined: Jan 2014

Reputation:

FCoin: 13.45ƒc
ForNesia LoversBitcoin DonaturExtreme StaffTrusted PersonLegendary ForNesiaTop Poster
closed

Solved jabatangan

Sent from my ASUS_T00I using Tapatalk

[Image: coollogo_com_5514825.gif]




Possibly Related Threads...
Thread: Author Last Post
  [Ask] Payload Injek filter AVG tsel Galaxi 04-01-2014 02:57 PM
Last Post: bayek

Search thread:


[-]
Advertisement