#!/usr/bin/perl -w use Win32::API '0.70'; use Win32::API::Test; use Encode; use Carp; $test_dll = Win32::API::Test::find_test_dll(); Win32::API::Struct->typedef('WLAN_CONNECTION_PARAMETERS', qw( WLAN_CONNECTION_MODE wlanConnectionMode; LPCWSTR strProfile; PDOT11_SSID pDot11Ssid; PDOT11_BSSID_LIST pDesiredBssidList; DOT11_BSS_TYPE dot11BssType; DWORD dwFlags; )); Win32::API::Struct->typedef ('DOT11_SSID', qw( ULONG uSSIDLength; UCHAR ucSSID; )); $api = Win32::API->new($test_dll, 'WlanConnect', 'IPPI', 'I'); $wlan_available = 1; sub 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('DOT11_SSID'); $pDot11Ssid->{uSSIDLength} = length $ssid; $pDot11Ssid->{ucSSID} = $ssid; my $Wlan_connection_parameters = Win32::API::Struct->new('WLAN_CONNECTION_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; $api->Call($handle, $guuid, $Wlan_connection_parameters, 0) == 1234 or die "bad ret"; }; WlanConnect(1, "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16", Encode::encode("UTF-16LE","TheProfileName"), "TheSSID");