Hi, thanks for your reply. I'm not entirely sure how this module would be able to return a list of the nodes available on a network. It seems to identify those with shared resources. I tested the example enumerating all resources on a network, and it only picked up on my pc and not others on the network.
Jenni | [reply] |
You said,
...list of all devices available on a local network ,
and those are, imho, shared devices/network printers etc.
What exactly are you trying to achieve?
| [reply] |
Oh I see, that was my fault. I want to basically retrieve a list of all machines the can be seen on a LAN. Similar to 'My Network Places' in Windows.
Sorry about the confusion, Jen
| [reply] |
Hi all, have been working on it a while now and just can't seem to get the code working.
To recap and confirm, it is supposed to return all nodes on a network by accessing Windows WNet API functions.
#!/usr/bin/perl
use strict;
use Win32::API::Prototype;
# WNetOpenEnum variables
my $dwScope = "RESOURCE_CONNECTED";
my $dwType = "RESOURCETYPE_ANY";
my $dwUsage = "0";
my $lpNetResource = "NULL"; # assumes the ro
+ot of the network
my $lphEnum;
# WNetEnumResource variables
my $hEnum; # must be return
+ed by WNetOpenEnum
my $lpcCount = "-1"; # returns as ma
+ny entries as possible
my $lpBufferSize = "16384"; # specifies the
+size of the lpBuffer parameter
my $lpBuffer = AllocMemory( 16384 ); # points to the
+ buffer that receives the emuneration results
# WNetOpenEnum
ApiLink('mpr.dll',
'DWORD WNetOpenEnum(DWORD dwScope, DWORD dwType, DWORD dwUsage
+, LPNETRESOURCE lpNetResource, LPHANDLE lphEnum)');
# WNetEnumResource
ApiLink('mpr.dll',
'DWORD WNetEnumResource(HANDLE hEnum, LPDWORD lpcCount, LPVOID
+ lpBuffer, LPDWORD lpBufferSize)');
# WNetCloseEnum
ApiLink('mpr.dll',
'DWORD WNetCloseEnum(HANDLE hEnum)');
WNetOpenEnum($dwScope, $dwType, $dwUsage, $lpNetResource, $lphEnum);
$hEnum = $lphEnum;
my $dwResultEnum = WNetEnumResource($hEnum, $lpcCount, $lpBuffer, $lpB
+ufferSize);
# // get remote name of resource... lpnrLocal[i].lpRemoteName)
do
{
if($dwResultEnum eq "NO_ERROR")
{
for (my $i = 0; $i < $lpcCount; $i++)
{
CleanString( $lpBuffer );
print $lpBuffer->[$i];
}
}
elsif($dwResultEnum ne "ERROR_NO_MORE_ITEMS")
{
exit;
}
}
while($dwResultEnum ne "ERROR_NO_MORE_ITEMS");
$lpBuffer = '';
my $dwResult = WNetCloseEnum($hEnum);
Can anyone tell me what is wrong, literally nothing is returned so im not sure if im using the Win32-API-Prototype module correctly at all.
Thanks in advance, Jen | [reply] [d/l] |