Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   C++ Builder (https://www.clubdelphi.com/foros/forumdisplay.php?f=13)
-   -   Si alguien tiene tiempo y puede convertir estas funciones a C++ Builder (https://www.clubdelphi.com/foros/showthread.php?t=91703)

Snaked 04-04-2017 18:20:13

Si alguien tiene tiempo y puede convertir estas funciones a C++ Builder
 
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;
        
ProfileString;
        
SSIDString;
        
Signalinteger;
        
AuthString;
        
ConectedBOOL;
      
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
      
hClientTHandle;
      
dwVersionDWORD;
      
pInterfaceInfoListPWLAN_INTERFACE_INFO_LIST;
      
pInterfaceGuidPGUID;
      
pNetworkListPWLAN_AVAILABLE_NETWORK_LIST;
      
ijinteger;
    
begin
      Result
:= 0;
      if 
ERROR_SUCCESS WlanOpenHandle(1nil, @dwVersion, @hClientthen
      begin
        
if ERROR_SUCCESS WlanEnumInterfaces(hClientnil, @pInterfaceInfoListthen
        begin
          
for := 0 to pInterfaceInfoList^.dwNumberOfItems do
          
begin
            pInterfaceGuid
:= @pInterfaceInfoList^.InterfaceInfo[pInterfaceInfoList^.dwIndex].InterfaceGuid;
            if 
ERROR_SUCCESS WlanGetAvailableNetworkList(hClientpInterfaceGuid1nilpNetworkListthen
            begin
              
for := 0 to pNetworkList^.dwNumberOfItems 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(hClientnil);
      
end;
    
end;
     
    function 
WifiConect(SSIDWideString): BOOL;
    var
      
hClientTHandle;
      
dwVersionDWORD;
      
pInterfaceInfoListPWLAN_INTERFACE_INFO_LIST;
      
pInterfaceGuidPGUID;
      
iinteger;
      
pWLCPPWLAN_CONNECTION_PARAMETERS;
    
begin
      Result
:= false;
      if 
ERROR_SUCCESS WlanOpenHandle(1nil, @dwVersion, @hClientthen
      begin
        
if ERROR_SUCCESS WlanEnumInterfaces(hClientnil, @pInterfaceInfoListthen
        begin
          
for i:= 0 to pInterfaceInfoList^.dwNumberOfItems 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(hClientpInterfaceGuidpWLCPnil));
            
WlanFreeMemory(pWLCP);
          
end;
          
WlanFreeMemory(pInterfaceInfoList);
        
end;
        
WlanCloseHandle(hClientnil);
      
end;
    
end;
     
    function 
WifiDisConectBOOL;
    var
      
hClientTHandle;
      
dwVersionDWORD;
      
pInterfaceInfoListPWLAN_INTERFACE_INFO_LIST;
      
pInterfaceGuidPGUID;
      
iinteger;
    
begin
      Result
:= false;
      if 
ERROR_SUCCESS WlanOpenHandle(1nil, @dwVersion, @hClientthen
      begin
        
if ERROR_SUCCESS WlanEnumInterfaces(hClientnil, @pInterfaceInfoListthen
        begin
          
for i:= 0 to pInterfaceInfoList^.dwNumberOfItems do
          
begin
            pInterfaceGuid
:= @pInterfaceInfoList^.InterfaceInfo[pInterfaceInfoList^.dwIndex].InterfaceGuid;
            
WlanDisconnect(hClientpInterfaceGuidnil);
          
end;
          
WlanFreeMemory(pInterfaceInfoList);
        
end;
        
WlanCloseHandle(hClientnil);
      
end;
    
end


escafandra 06-04-2017 20:44:46

Aunque el código publicado en los foros es libre, es una excelente y elegante costumbre publicar la fuente del lugar donde se copió y una forma de agradecer al autor su contribución: Jugando con las conexiones Wifi

Saludos.

Casimiro Notevi 07-04-2017 01:03:36

Cita:

Empezado por escafandra (Mensaje 515279)
Aunque el código publicado en los foros es libre, es una excelente y elegante costumbre publicar la fuente del lugar donde se copió y una forma de agradecer al autor su contribución: Jugando con las conexiones Wifi

Saludos.

^\||/^\||/^\||/


La franja horaria es GMT +2. Ahora son las 08:18:41.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi