Win32::NetResource - manage network resources in perl
use Win32::NetResource; $ShareInfo = { 'path' => "C:\\MyShareDir", 'netname' => "MyShare", 'remark' => "It is good to share", 'passwd' => "", 'current-users' =>0, 'permissions' => 0, 'maxusers' => -1, 'type' => 0, }; Win32::NetResource::NetShareAdd( $ShareInfo,$parm ) or die "unable to add share";
This module offers control over the network resources of Win32.Disks, printers etc can be shared over a network.
There are two main data types required to control network resources. In Perl these are represented by hash types.
KEY VALUE 'Scope' => Scope of an Enumeration RESOURCE_CONNECTED, RESOURCE_GLOBALNET, RESOURCE_REMEMBERED. 'Type' => The type of resource to Enum RESOURCETYPE_ANY All resources RESOURCETYPE_DISK Disk resources RESOURCETYPE_PRINT Print resources 'DisplayType' => The way the resource should be displayed. RESOURCEDISPLAYTYPE_DOMAIN The object should be displayed as a domain. RESOURCEDISPLAYTYPE_GENERIC The method used to display the object does not matter. RESOURCEDISPLAYTYPE_SERVER The object should be displayed as a server. RESOURCEDISPLAYTYPE_SHARE The object should be displayed as a sharepoint. 'Usage' => Specifies the Resources usage: RESOURCEUSAGE_CONNECTABLE RESOURCEUSAGE_CONTAINER. 'LocalName' => Name of the local device the resource is connected to. 'RemoteName' => The network name of the resource. 'Comment' => A string comment. 'Provider' => Name of the provider of the resource.
This hash represents the SHARE_INFO_502 struct.
KEY VALUE 'netname' => Name of the share. 'type' => type of share. 'remark' => A string comment. 'permissions' => Permissions value 'maxusers' => the max # of users. 'current-users' => the current # of users. 'path' => The path of the share. 'passwd' => A password if one is req'd
All of the functions return FALSE (0) if they fail.
Creates a list in @Resources of %NETRESOURCE hash references.
Makes a connection to a network resource specified by %NETRESOURCE
Cancels a connection to a network resource connected to local device $name.$Connection is either 1 - persistent connection or 0, non-persistent.
Gets the Extended Network Error.
Gets the last Error for a Win32::NetResource call.
Returns the UNC name of the disk share connected to $LocalPath in $UNCName.
$servername is optional for all the calls below. (if not given the local machine is assumed.)
Add a share for sharing.
Check if a share is available for connection.
Remove a share from a machines list of shares.
Get the %SHARE_INFO information about the share $netname on the server $servername.
Set the information for share $netname.
Jesse Dougherty for Hip Communications. Gurusamy Sarathy <gsar@umich.edu> had to clean up the horrendous code and the bugs.
4 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
You forgot a '=back' before '=head2'
To install Win32, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32
CPAN shell
perl -MCPAN -e shell install Win32
For more information on module installation, please visit the detailed CPAN module installation guide.