For the greater good:
NAME Win32::NetResource - manage network resources in perl SYNOPSIS 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"; DESCRIPTION This module offers control over the network resources of Win32.Dis +ks, printers etc can be shared over a network. DATA TYPES There are two main data types required to control network resource +s. In Perl these are represented by hash types. %NETRESOURCE KEY VALUE 'Scope' => Scope of an Enumeration RESOURCE_CONNECTED, RESOURCE_GLOBALNET, RESOURCE_REMEMBERED. 'Type' => The type of resource to Enum RESOURCETYPE_ANY All reso +urces RESOURCETYPE_DISK Disk re +sources RESOURCETYPE_PRINT Print +resources 'DisplayType' => The way the resource should +be displayed. RESOURCEDISPLAYTYPE_DOMAIN + The object should be display +ed as a domain. RESOURCEDISPLAYTYPE_GENERIC + The method used to display t +he object does not matter. RESOURCEDISPLAYTYPE_SERVER + The object should be display +ed as a server. RESOURCEDISPLAYTYPE_SHARE + The object should be display +ed as a sharepoint. 'Usage' => Specifies the Resources usag +e: RESOURCEUSAGE_CONNECTABLE RESOURCEUSAGE_CONTAINER. 'LocalName' => Name of the local device the + resource is connected to. 'RemoteName' => The network name of the reso +urce. 'Comment' => A string comment. 'Provider' => Name of the provider of the +resource. %SHARE_INFO 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 FUNCTIONS NOTE All of the functions return FALSE (0) if they fail. GetSharedResources(\@Resources,dwType) Creates a list in @Resources of %NETRESOURCE hash refere +nces. The return value indicates whether there was an error in accessing any of the shared resources. All the shared resources that were encountered (until the point of an e +rror, if any) are pushed into @Resources as references to %NETRESOURCE hashes. See example below. AddConnection(\%NETRESOURCE,$Password,$UserName,$Connection) Makes a connection to a network resource specified by %NETRESOURCE CancelConnection($Name,$Connection,$Force) Cancels a connection to a network resource connected to +local device $name.$Connection is either 1 - persistent connec +tion or 0, non-persistent. WNetGetLastError($ErrorCode,$Description,$Name) Gets the Extended Network Error. GetError( $ErrorCode ) Gets the last Error for a Win32::NetResource call. GetUNCName( $UNCName, $LocalPath ); Returns the UNC name of the disk share connected to $Loc +alPath in $UNCName. NOTE $servername is optional for all the calls below. (if not + given the local machine is assumed.) NetShareAdd(\%SHARE,$parm_err,$servername = NULL ) Add a share for sharing. NetShareCheck($device,$type,$servername = NULL ) Check if a share is available for connection. NetShareDel( $netname, $servername = NULL ) Remove a share from a machines list of shares. NetShareGetInfo( $netname, \%SHARE,$servername=NULL ) Get the %SHARE_INFO information about the share $netname + on the server $servername. NetShareSetInfo( $netname,\%SHARE,$parm_err,$servername=NULL) Set the information for share $netname. EXAMPLE # # This example displays all the share points in the entire # visible part of the network. # use strict; use Win32::NetResource qw(:DEFAULT GetSharedResources GetError +); my $resources = []; unless(GetSharedResources($resources, RESOURCETYPE_ANY)) { my $err = undef; GetError($err); warn Win32::FormatMessage($err); } foreach my $href (@$resources) { next if ($$href{DisplayType} != RESOURCEDISPLAYTYPE_SHARE) +; print "-----\n"; foreach( keys %$href){ print "$_: $href->{$_}\n"; } }
--
Casey

In reply to RE: RE: Re: External programs by cwest
in thread External programs by clrobert

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.