I also changed main for null safety and to work on my machinesub WlanConnect { croak "Wlan functions are not available" unless $wlan_available; my ($handle, $guuid, $profilename, $ssid) = @_; # possibly overkill, a pDot11Ssid = 0 should suffice #my $pDot11Ssid = Win32::API::Struct->new('PDOT11_SSID'); #$pDot11Ssid->{uSSIDLength} = length $ssid; #$pDot11Ssid->{ucSSID} = $ssid; my $SSIDstruct = pack('LZ[32]',length $ssid, $ssid ); #not overflo +w checked my $Wlan_connection_parameters = pack('LPPJLL', 0, $profilename, $ +SSIDstruct, 0, 3, 0); #$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 "; }
I dont think my pack codes work on x64 BTW. Perhaps another monk can rewrite them to be portable, or you can just make another SOPW post.sub main { $ARGV[0] = 'removed'; $ARGV[1] = 'removed'; die "USAGE: $0 PROFILENAME SSID\n" unless($ARGV[1]); my $profilename = $ARGV[0]; my $ssid = $ARGV[1]; my $wlan_handle = WlanOpenHandle(); my @interfaces = WlanEnumInterfaces($wlan_handle); my $wlan_guuid = $interfaces[0]->{guuid}; $profilename = encode('UTF-16LE', $profilename."\x00"); WlanConnect($wlan_handle, $wlan_guuid, $profilename, $ssid); }
In reply to Re^10: Adding WlanConnect() to Win32::Wlan::API (structs no go?)
by bulk88
in thread Adding WlanConnect() to Win32::Wlan::API
by tomsell
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |