Link to home
Start Free TrialLog in
Avatar of wangzheng
wangzheng

asked on

Delphi call winpcap and detect network adapter

Hello everyone:

I used Delphi codes  to cal winpcap to detect network adapter:

******************************************************************************************
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
        pDevice: PChar;
    errBuffArray: Array[0..1000] of PAnsiChar;
  public
    { Public declarations }
  end;


var
  Form1: TForm1;

  function pcap_lookupdev(errBuff: Array of PAnsiChar): PChar; cdecl; external 'wpcap.dll';

implementation

{$R *.dfm}

 
procedure TForm1.Button1Click(Sender: TObject);
begin
  pDevice := pcap_lookupdev(errBuffArray);
  ShowMessage('device: ' + pDevice);
end;

end.

*****************************************************************

but output result  always display 'device:\' rather than display the device name.

and if I call  

pcap_loop
pcap_open_live
pcap_findalldevs

..etc

I still can get the device id/name on xp

but it does not work on vista.

Welcome any comment.

Best Regards

Z Wang
Avatar of MerijnB
MerijnB
Flag of Netherlands image

I'm I correct in understanding that your code did work on XP and does not work anymore on Vista?
ASKER CERTIFIED SOLUTION
Avatar of Johnjces
Johnjces
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wangzheng
wangzheng

ASKER

Your answer is correct.

But when I install the final exe file on xp, each time when I run the program, norton antivirus jump out and ask for user's confirmation to run, so boring!


:-(
Norton Anti-Virus? What version? That is weird as I have not seen that with the corporate edition latest version 10.x.

You might need two seperate versions. ONe for XP and one for Vista, which is not that uncommon.

Vista may and still will ask for user and password to enforce user permissions.

Your problem is strange and hopefully someone knows something about that kind of issue.

John
Sorry, I made mistake.
I mean on vista, if I use manifest like your wrote, vista system will add a small icon on my program icon on the desktop.

Everytime when an user run my program, vista will always ask for use's confirmation.

Best Regards

Z Wang
That is what Vista does!

There is no way around it unless you disable all the security (UAC stuf) in Vista. Otherwise  it will continue to do that.

Welcome to Vista!

John
Forced accept.

Computer101
EE Admin