Dismiss Notice

REGISTRATION IS AFTER ADMIN ACTIVATION

DONATIONS WITH PAYPAL CLICK TO BUTTON

3 MONTHS VIP - 10$; 6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$

DONATIONS WITH Bitcoin Address:3NRs3CK3fhXifrNYxHEZKpETDd9vNLMsMD

Dismiss Notice
The registration is approved by the Administrator. It takes about 1 day to approve your registration
Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Detecting Wifi Networks Using Delphi and Native Wifi API

Discussion in 'Delphi Programming' started by N0body, Feb 22, 2014.

  1. N0body
    Online

    N0bodyN0body is a Verified Member DelphiFan Administrator Staff Member DF Staff

    Code:
    {$APPTYPE CONSOLE}
     
    uses
      Windows,
      SysUtils,
      nduWlanAPI   in 'nduWlanAPI.pas',
      nduWlanTypes in 'nduWlanTypes.pas';
     
    function DOT11_AUTH_ALGORITHM_To_String( Dummy :Tndu_DOT11_AUTH_ALGORITHM):AnsiString;
    begin
        Result:='';
        case Dummy of
            DOT11_AUTH_ALGO_80211_OPEN          : Result:= '80211_OPEN';
            DOT11_AUTH_ALGO_80211_SHARED_KEY    : Result:= '80211_SHARED_KEY';
            DOT11_AUTH_ALGO_WPA                 : Result:= 'WPA';
            DOT11_AUTH_ALGO_WPA_PSK             : Result:= 'WPA_PSK';
            DOT11_AUTH_ALGO_WPA_NONE            : Result:= 'WPA_NONE';
            DOT11_AUTH_ALGO_RSNA                : Result:= 'RSNA';
            DOT11_AUTH_ALGO_RSNA_PSK            : Result:= 'RSNA_PSK';
            DOT11_AUTH_ALGO_IHV_START           : Result:= 'IHV_START';
            DOT11_AUTH_ALGO_IHV_END             : Result:= 'IHV_END';
        end;
    end;
     
    function DOT11_CIPHER_ALGORITHM_To_String( Dummy :Tndu_DOT11_CIPHER_ALGORITHM):AnsiString;
    begin
        Result:='';
        case Dummy of
        DOT11_CIPHER_ALGO_NONE      : Result:= 'NONE';
        DOT11_CIPHER_ALGO_WEP40     : Result:= 'WEP40';
        DOT11_CIPHER_ALGO_TKIP      : Result:= 'TKIP';
        DOT11_CIPHER_ALGO_CCMP      : Result:= 'CCMP';
        DOT11_CIPHER_ALGO_WEP104    : Result:= 'WEP104';
        DOT11_CIPHER_ALGO_WPA_USE_GROUP : Result:= 'WPA_USE_GROUP OR RSN_USE_GROUP';
        //DOT11_CIPHER_ALGO_RSN_USE_GROUP : Result:= 'RSN_USE_GROUP';
        DOT11_CIPHER_ALGO_WEP           : Result:= 'WEP';
        DOT11_CIPHER_ALGO_IHV_START     : Result:= 'IHV_START';
        DOT11_CIPHER_ALGO_IHV_END       : Result:= 'IHV_END';
        end;
    end;
     
    procedure Scan();
    const
    WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_ADHOC_PROFILES =$00000001;
    var
      hClient              : THandle;
      dwVersion            : DWORD;
      ResultInt            : DWORD;
      pInterface           : Pndu_WLAN_INTERFACE_INFO_LIST;
      i                    : Integer;
      j                    : Integer;
      pAvailableNetworkList: Pndu_WLAN_AVAILABLE_NETWORK_LIST;
      pInterfaceGuid       : PGUID;
      SDummy               : AnsiString;
    begin
      ResultInt:=WlanOpenHandle(1, nil, @dwVersion, @hClient);
       try
        if  ResultInt<> ERROR_SUCCESS then
        begin
           WriteLn('Error Open CLient'+IntToStr(ResultInt));
           Exit;
        end;
     
        ResultInt:=WlanEnumInterfaces(hClient, nil, @pInterface);
        if  ResultInt<> ERROR_SUCCESS then
        begin
           WriteLn('Error Enum Interfaces '+IntToStr(ResultInt));
           exit;
        end;
     
        for i := 0 to pInterface^.dwNumberOfItems - 1 do
        begin
         Writeln('Interface       ' + pInterface^.InterfaceInfo.strInterfaceDescription);
         WriteLn('GUID            ' + GUIDToString(pInterface^.InterfaceInfo.InterfaceGuid));
         Writeln('');
         pInterfaceGuid:= @pInterface^.InterfaceInfo[pInterface^.dwIndex].InterfaceGuid;
     
            ResultInt:=WlanGetAvailableNetworkList(hClient,pInterfaceGuid,WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_ADHOC_PROFILES,nil,pAvailableNetworkList);
            if  ResultInt<> ERROR_SUCCESS then
            begin
               WriteLn('Error WlanGetAvailableNetworkList '+IntToStr(ResultInt));
               Exit;
            end;
     
              for j := 0 to pAvailableNetworkList^.dwNumberOfItems - 1 do
              Begin
                 WriteLn(Format('Profile         %s',[WideCharToString(pAvailableNetworkList^.Network[j].strProfileName)]));
                 SDummy:=PAnsiChar(@pAvailableNetworkList^.Network[j].dot11Ssid.ucSSID);
                 WriteLn(Format('NetworkName     %s',[SDummy]));
                 WriteLn(Format('Signal Quality  %d ',[pAvailableNetworkList^.Network[j].wlanSignalQuality])+'%');
                 //SDummy := GetEnumName(TypeInfo(Tndu_DOT11_AUTH_ALGORITHM),integer(pAvailableNetworkList^.Network[j].dot11DefaultAuthAlgorithm)) ;
                 SDummy:=DOT11_AUTH_ALGORITHM_To_String(pAvailableNetworkList^.Network[j].dot11DefaultAuthAlgorithm);
                 WriteLn(Format('Auth Algorithm  %s ',[SDummy]));
                 SDummy:=DOT11_CIPHER_ALGORITHM_To_String(pAvailableNetworkList^.Network[j].dot11DefaultCipherAlgorithm);
                 WriteLn(Format('Auth Algorithm  %s ',[SDummy]));
                 Writeln('');
              End;
        end;
       finally
        WlanCloseHandle(hClient, nil);
       end;
    end;
    begin
      try
        Scan();
        Readln;
      except
        on E:Exception do
          Writeln(E.Classname, ': ', E.Message);
      end;
    end.
     
  2. falcon2000
    Online

    falcon2000 Guest

    Thanks for share !
     
  3. gobanggobing
    Offline

    gobanggobing DF Member

    nice inform, master
     
  4. dynamo
    Offline

    dynamo DF Expert

    Thanks
     
  5. rricos
    Offline

    rricos DF Member

    Thanks
     
  6. acoustique
    Offline

    acoustique DF Member

    Thank you for this
     
  7. stavroula2011
    Offline

    stavroula2011 DF Senior

  8. a_marwan
    Offline

    a_marwan DF Member

    RE:

    Thanks for sharing, but can't find the referenced files:

    nduWlanAPI in 'nduWlanAPI.pas',
    nduWlanTypes in 'nduWlanTypes.pas'
     
    HeCaRe likes this.
  9. SjjDialer
    Online

    SjjDialer Guest

    RE:

    thanks
     
  10. momo
    Online

    momo Guest

    you can find it
    http://www.delphibasics.info/home/delphibasicsprojects/wifiscanner/WlanAPI.rar
     
  11. chimotoki
    Offline

    chimotoki DF Junior

    RE:

    Tahnk you
     
  12. RcXXcR
    Online

    RcXXcR Guest

    RE:

    thanks :)
     
  13. jekl
    Offline

    jekl DF Junior

    RE:

    thanks
     
  14. bastel
    Offline

    bastel DF Junior

    Hey man.

    i have testet the source and i am happy. Many thanks for this.

    cu Bastel
     
  15. peyman1
    Online

    peyman1 Guest

    RE:

    thanks
     
  16. brianchidester
    Online

    brianchidester Guest

  17. happyleaman
    Online

    happyleaman Guest

    RE:

    Good idea!Thanks for sharing the code.
     
  18. deft
    Offline

    deft DF Member

    RE:

    thank you
     
  19. jpll
    Offline

    jplljpll is a Verified Member DF Junior

    I'l try, thanks
     
  20. hatm
    Offline

    hatm DF Junior

    RE:

    Thanks!
     

Share This Page

Laws
Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.
Donate Help To Us and Be VIP
DONATIONS WITH PAYPAL CLICK TO BUTTON
6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$
Social Block