access ARP table in Win32

P

perl coder

I need to read the contents of the ARP table from a Win32 GUI program
(ActiveState "perlapp -gui" binary). Since the -gui switch disables
the stdin/out/err file descriptors, I can't just parse the output from
arp.exe or even redirect it to a file. So I need a way to access the ARP
tables from wherever arp.exe is getting its data from (presumably a system
call). Is there a module that does this? Or does anyone happen to know
which system call? (maybe Win32-API will work then)
 
P

Petri

So I need a way to access the ARP tables from wherever arp.exe
is getting its data from (presumably a system call).
Is there a module that does this?

Why ask when you can look for yourself?

http://search.cpan.org/search?query=ARP&mode=all
Or does anyone happen to know which system call? (maybe Win32-API will work
then)

What did you find when you searched for it?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/getipnettable.asp


Petri
 
P

perl coder

Purl Gurl said:
Arp is not a GUI program. To obtain results, don't run it
as an ActiveState perlapp binary.

I was meaning that it was my program that was created with "perlapp
-gui". :)
print `arp -a`;
print `ipconfig`;
system ("arp -a");
system ("ipconfig");

Yeah I know all those. I even tried with Win32::process to make a
detached process (so no console windows pop up).
Use of -gui with perlapp does not disable input
nor output, it simply creates an executable which
does not generate a console.

From what I can tell so far, a "perlapp -gui" binary has no longer
access to the standard file descriptors (STDIN, STDOUT, STDERR) and
those file descriptors cannot exist without a console window. I ran
several tests with such programs, trying to get output from arp.exe (and
other console commands) and got nothing at all. Redirecting output to a
file created an empty file.

A little bit of googling also revealed that exe's can be linked to not
have those file descriptors, and presumably that's what perlapp has to
do to make a pure GUI application.
Run your perlapp from a DOS box or run it from your
command line with appropriate redirect switches
for output.

Don't want any console windows on the screen. Console windows will
freak out the users. It's for windows, so it has to be 100% GUI, and
very very pretty with lots of clicky-clicky buttons. Blah! ;-)

Not even minimized console windows in fact. Just pure GUI. If I could
afford a console window, there wouldn't be any problem with calling
arp.exe.
 
P

perl coder

Petri said:
Why ask when you can look for yourself?

Cause I'm programming in windows and it's making my brain hurt. :-(
What did you find when you searched for it?

I found stuff about a GetIpNetTable system call that doesn't work in
Win95 or WinNT before sevice pack 4. And apparently before that you had
to use SNMP to access some local MIB table. That's crazy talk!

Well at least I don't have to parse the registry. :) :) :)

Thanks. But how come when I follow this URL with Lynx, Microsoft
decides to hijack my browser and take me to this place instead:
http://msdn.microsoft.com/library/shared/deeptree/bot/bot.asp?dtcnfg=/library/deeptreeconfig.xml

We hates the Microsoft! We hates them!
 
P

Petri

I found stuff about a GetIpNetTable system call that doesn't work
in Win95 or WinNT before sevice pack 4.

Tell me you aren't developing for those ancient platforms...
Well at least I don't have to parse the registry. :) :) :)

Why not, that would be an easy solution at this stage.
Thanks. But how come when I follow this URL with Lynx,
Microsoft decides to hijack my browser and take me to this
place instead:

Why lynx if you are developing on Windows anyway?

If you really can't catch any output with backticks, then maybe you should
consider dumping the output of arp -a into a file and then opening that file in
your application?
Something like (untested):
---8<---
use strict;
use warnings;
system('arp -a > %temp%/arp.txt');
open my $arp, '<', "$ENV{TEMP}/arp.txt" or die "Can't open '$ENV{TEMP}/arp.txt':
$!";
---8<---

Unless system() doesn't work at all for you, of course.


Petri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top