Tengo estas 2 funciones que me gustaria probar pero estan en Delphi y yo estoy con C++ Builder
solo si alguien tiene algo de tiempo y me las podria convertir para probarlas a ver si son mejores que las que estoy usando
un saludo y gracias por el interes
Código PHP:
type
TWifiData = record
InterfaceInfo: String;
Profile: String;
SSID: String;
Signal: integer;
Auth: String;
Conected: BOOL;
end;
function WifiScan(var List: array of TWifiData): integer;
const
AuthStr: array [1..9]of String = ('Open','Shared Key','WPA','WPA-PSK','WPA NONE','RSNA','RSNA-PSK','IHV Start','IHV End');
var
hClient: THandle;
dwVersion: DWORD;
pInterfaceInfoList: PWLAN_INTERFACE_INFO_LIST;
pInterfaceGuid: PGUID;
pNetworkList: PWLAN_AVAILABLE_NETWORK_LIST;
i, j: integer;
begin
Result:= 0;
if ERROR_SUCCESS = WlanOpenHandle(1, nil, @dwVersion, @hClient) then
begin
if ERROR_SUCCESS = WlanEnumInterfaces(hClient, nil, @pInterfaceInfoList) then
begin
for i := 0 to pInterfaceInfoList^.dwNumberOfItems - 1 do
begin
pInterfaceGuid:= @pInterfaceInfoList^.InterfaceInfo[pInterfaceInfoList^.dwIndex].InterfaceGuid;
if ERROR_SUCCESS = WlanGetAvailableNetworkList(hClient, pInterfaceGuid, 1, nil, pNetworkList) then
begin
for j := 0 to pNetworkList^.dwNumberOfItems - 1 do
begin
Result:= pNetworkList^.dwNumberOfItems;
with List[j] do
begin
InterfaceInfo:= pInterfaceInfoList^.InterfaceInfo[0].strInterfaceDescription;
Profile:= WideCharToString(pNetworkList^.Network[j].strProfileName);
SSID:= PChar(@pNetworkList^.Network[j].dot11Ssid.ucSSID);
Signal:= pNetworkList^.Network[j].wlanSignalQuality;
Auth:= AuthStr[pNetworkList^.Network[j].dot11DefaultAuthAlgorithm];
Conected:= (pNetworkList^.Network[j].dwFlags and WLAN_AVAILABLE_NETWORK_CONNECTED) <> 0;
end;
end;
WlanFreeMemory(pNetworkList);
end;
end;
WlanFreeMemory(pInterfaceInfoList);
end;
WlanCloseHandle(hClient, nil);
end;
end;
function WifiConect(SSID: WideString): BOOL;
var
hClient: THandle;
dwVersion: DWORD;
pInterfaceInfoList: PWLAN_INTERFACE_INFO_LIST;
pInterfaceGuid: PGUID;
i: integer;
pWLCP: PWLAN_CONNECTION_PARAMETERS;
begin
Result:= false;
if ERROR_SUCCESS = WlanOpenHandle(1, nil, @dwVersion, @hClient) then
begin
if ERROR_SUCCESS = WlanEnumInterfaces(hClient, nil, @pInterfaceInfoList) then
begin
for i:= 0 to pInterfaceInfoList^.dwNumberOfItems - 1 do
begin
pInterfaceGuid:= @pInterfaceInfoList^.InterfaceInfo[pInterfaceInfoList^.dwIndex].InterfaceGuid;
pWLCP:= WlanAllocateMemory(sizeof(TWLAN_CONNECTION_PARAMETERS));
pWLCP.strProfile:= PWCHAR(SSID);
pWLCP.wlanConnectionMode:= 0;
pWLCP.pDot11Ssid:= nil; //pDot11_DDSI;
pWLCP.pDesiredBssidList:= nil;
pWLCP.dot11BssType:= 1;
pWLCP.dwFlags:= 0;//$F;
Result:= (ERROR_SUCCESS = WlanConnect(hClient, pInterfaceGuid, pWLCP, nil));
WlanFreeMemory(pWLCP);
end;
WlanFreeMemory(pInterfaceInfoList);
end;
WlanCloseHandle(hClient, nil);
end;
end;
function WifiDisConect: BOOL;
var
hClient: THandle;
dwVersion: DWORD;
pInterfaceInfoList: PWLAN_INTERFACE_INFO_LIST;
pInterfaceGuid: PGUID;
i: integer;
begin
Result:= false;
if ERROR_SUCCESS = WlanOpenHandle(1, nil, @dwVersion, @hClient) then
begin
if ERROR_SUCCESS = WlanEnumInterfaces(hClient, nil, @pInterfaceInfoList) then
begin
for i:= 0 to pInterfaceInfoList^.dwNumberOfItems - 1 do
begin
pInterfaceGuid:= @pInterfaceInfoList^.InterfaceInfo[pInterfaceInfoList^.dwIndex].InterfaceGuid;
WlanDisconnect(hClient, pInterfaceGuid, nil);
end;
WlanFreeMemory(pInterfaceInfoList);
end;
WlanCloseHandle(hClient, nil);
end;
end;