Internally, Win32::API 0.45 still generates a garbage struct since your using undefined Win32::API types.C:\Documents and Settings\Owner\Desktop\cpan libs\Win32-Wlan-0.06>perl + wlan.pl The system cannot find the file specified at C:/perl512/site/lib/Win32 +/Wlan/API. pm line 381, <DATA> line 164. C:\Documents and Settings\Owner\Desktop\cpan libs\Win32-Wlan-0.06>perl + -MWin32:: API -MWin32::Wlan::API -e "print $Win32::API::VERSION" 0.45 C:\Documents and Settings\Owner\Desktop\cpan libs\Win32-Wlan-0.06>
$packing contains "SL". I modified Wlan::API's WlanConnect to#from Win32::API::Struct 0.45 sub Pack { my $self = shift; my($packing, $items, $recipients) = $self->getPack(); DEBUG "(PM)Struct::Pack: $self->{__typedef__}(buffer) = pack($pack +ing, @$items)\n"; $self->{buffer} = pack($packing, @$items); if(DEBUG) { for my $i (0..$self->sizeof-1) { printf " %3d: 0x%02x\n", $i, ord(substr($self->{buffer} +, $i, 1)); } } $self->{buffer_recipients} = $recipients }
and reran it under Win32::API, 0.45.sub WlanConnect { croak "Wlan functions are not available" unless $wlan_available; my ($handle, $guuid, $profilename, $ssid) = @_; my $pDot11Ssid = Win32::API::Struct->new('DOT11_SSID'); $pDot11Ssid->{uSSIDLength} = length $ssid; $pDot11Ssid->{ucSSID} = $ssid; my $Wlan_connection_parameters = Win32::API::Struct->new('WLAN_CON +NECTION_PARAMETERS'); $Wlan_connection_parameters->{wlanConnectionMode} = 0; $Wlan_connection_parameters->{strProfile} = $profilename; $Wlan_connection_parameters->{pDot11Ssid} = $pDot11Ssid; $Wlan_connection_parameters->{pDesiredBssidList} = 0; $Wlan_connection_parameters->{dot11BssType} = 3; $Wlan_connection_parameters->{dwFlags} = 0; my $reterr = $API{ WlanConnect }->Call($handle, $guuid, $Wlan_con +nection_parameters, 0); $reterr == 0 or die "WlanConnect return Error $reterr "; };
The work around is to use "INT" instead of enums specific types and keep a hash that converts enum slice names (as hash key names) to numeric equivalents (hash key value). Not all the things in WLAN_CONNECTION_PARAMETERS are enums. Some are pointers to other structs. Can I ask what level is your knowledge of C?C:\Documents and Settings\Owner\Desktop\cpan libs\Win32-Wlan-0.06>perl + wlan.pl WlanConnect return Error 87 at C:/perl512/site/lib/Win32/Wlan/API.pm +line 382, <DATA> line 164. C:\Documents and Settings\Owner\Desktop\cpan libs\Win32-Wlan-0.06>perl + -MWin32: API -MWin32::Wlan::API -e "print $Win32::API::VERSION" 0.45 C:\Documents and Settings\Owner\Desktop\cpan libs\Win32-Wlan-0.06>
In reply to Re^9: Adding WlanConnect() to Win32::Wlan::API (structs no go?)
by bulk88
in thread Adding WlanConnect() to Win32::Wlan::API
by tomsell
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |