Nash wrote:
Hi all,
I'm new to Perl and I'm trying to use it to connect to a shared disc
through a home network. This is what I've tried:
--------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
use Win32::NetResource;
$RemoteShare = {
'LocalName' => "X:",
'RemoteName' => "\\\\Nash",
};
$UserName = "No Name";
$Password = "";
$Connection = 1;
Win32::NetResource::AddConnection($RemoteShare,$Password,$UserName,
$Connection)
or print "unable to add Nash\n";
Win32::NetResource::GetError( $ErrorCode );
print "Error code is $ErrorCode";
-----------------------------------------------------------------------------------------------------------------------
The program actually works if I omit the 'LocalName' definition in
line 4, i.e. it makes the connection. However, since I don't have a
local name I can't subseqently cancel the connection, and I'd like to
be able to do that.
With the local name definition, the program doesn't make the
connection, reporting an error code of 1200.
So:
1. What am I doing wrong?
2. Where can I find the error codes and their meanings?
The error codes are Windows system error codes. They are listed here
http://msdn2.microsoft.com/en-us/library/ms681381(VS.85).aspx
Your remote name \\Nash isn't a resource name, it's just a node name.
Resource names look like \\Nash\Mydisk or \\Nash\laserprinter. To find
out what resources, if any, your node is sharing run the program below,
which generates a list of all valid NetResource data structures and
dumps them.
HTH,
Rob
use strict;
use warnings;
use Data::Dumper;
use Win32::NetResource qw( :DEFAULT GetSharedResources );
GetSharedResources(my $resources, RESOURCETYPE_DISK,
{RemoteName => '\\\\Nash'});
print Dumper $resources;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/