Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Win32-API-Prototype WNet

by Anonymous Monk
on Mar 01, 2005 at 18:12 UTC ( [id://435550]=note: print w/replies, xml ) Need Help??


in reply to Win32-API-Prototype WNet

Hi,

This is the progress I have made so far. Still not there and havent been able to get anything to output as yet.

#!/usr/bin/perl use strict; use Win32::API::Prototype; # NETRESOURCE #ApiLink('kernel.dll', # 'typedef struct _NETRESOURCE(DWORD dwScope, DWORD dwType,DWOR +D dwDisplayType, DWORD dwUsage, LPTSTR lpLocalName, LPTSTR lpRemoteNa +me, LPTSTR lpComment, LPTSTR lpProvider) NETRESOURCE'); # ---unable to parse function definition # WNetOpenEnum ApiLink('kernel32.dll', 'DWORD WNetOpenEnum(DWORD dwScope, DWORD dwType, DWORD dwUsage +, LPNETRESOURCE lpNetResource, LPHANDLE lphEnum)'); # WNetEnumResource ApiLink('kernel32.dll', 'DWORD WNetEnumResource(HANDLE hEnum, LPDWORD lpcCount, LPVOID + lpBuffer, LPDWORD lpBufferSize)'); # WNetCloseEnum ApiLink('kernel32.dll', 'DWORD WNetCloseEnum(HANDLE hEnum)'); # 4th WNetOpenEnum parameter - pointer to NETRESOURCE my $netresource = "NULL"; # assumes the root of the network # 5th WNetOpenEnum parameter - pointer to WNetEnumResource # define WNetEnumResource parameters my $hEnum; # must be returned by WNetOpenEnum my $lpcCount = "-1"; # returns as many entries as possible my $lpBuffer; # points to the buffer that receives +the emuneration results - don't know how to do this my $lpBufferSize = "16384"; # specifies the size of the lpBuffe +r parameter # actual pointer to WNetEnumResource my $WNetEnumResource = WNetEnumResource($hEnum, $lpcCount, $lpBuffer, +$lpBufferSize); # Process WNetEnumOpen to start enumeration of the network WNetOpenEnum("RESOURCE_CONNECTED", "RESOURCETYPE_ANY", 0, $netresource +, $WNetEnumResource); # To continue the enumeration, call WNetEnumResource

Replies are listed 'Best First'.
Re^2: Win32-API-Prototype WNet
by mdillon (Priest) on Mar 02, 2005 at 04:48 UTC
    First, you probably want to add use warnings after use strict. This may or may not make some warnings pop out.

    Next, if you look on the home page for Win32::API::Prototype, you'll see that all their examples of using ApiLink all have || die after them. This makes it so that the program will stop executing if it can't link the api call. It will also tell you what line it was on when it died. You can also add an informative message like "could not link WNetCloseEnum". Read all about it with perldoc -f die.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://435550]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-20 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found