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


In reply to Re^2: Win32-API-Prototype WNet by Anonymous Monk
in thread Win32-API-Prototype WNet by Anonymous Monk

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.