• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2342
  • Last Modified:

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
0
wangzheng
Asked:
wangzheng
1 Solution
 
MerijnBSr. Software EngineerCommented:
I'm I correct in understanding that your code did work on XP and does not work anymore on Vista?
0
 
JohnjcesCommented:
If you are using Vista and it works correctly under XP, you have a permissions issue that Vista enforces.

You must have a correct Vista Manifest compiled into your application which requests administrator rights.

Do a an EE search for Vista Manifest and you find how to do this fairly easily. Here's a good one.

http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22755023.html?sfQueryTermInfo=1+manifest+vista

John
0
 
wangzhengAuthor Commented:
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!


:-(
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
JohnjcesCommented:
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
0
 
wangzhengAuthor Commented:
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
0
 
JohnjcesCommented:
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
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now