Einzelnen Beitrag anzeigen

jogging_cat

Registriert seit: 2. Nov 2007
Ort: Langewiesen
14 Beiträge
 
Delphi 5 Enterprise
 
#19

Re: WLanManager WLanAPI

  Alt 3. Dez 2007, 09:18
Hi nitschchedu,

ich würde da auch gerne mitmachen. Bei mir hängt es aber derzeit.
Jetzt habe ich erst mal mitbekommen, dass WlanGetNetworkBssList unter XP SP2
nicht funktioniert. OK.

Dann hapert es noch bei WlanScan. Das klappt bei mir überhaupt nicht.
Weder mit noch ohne gestartetes Wlan. Klappt bei deiner Project1.exe
aber auch nicht so 100%ig. Gerade einmal habe ich im unteren Teil
Einträge gesehen.

Ich benötige erst mal Hilfe für WlanScan. Als erstes wird diese registrierte
CallBack-Prozedur nie aufgerufen. Der Aufruf passierte nur manchmal in einer
Umgebung mit schwachem Funk, da sah ich aber nur so was wie
wlan_notification_acm_disconnected

Ich hänge mal etwas Code von mir an. Wäre dankbar über eine Antwort.

Delphi-Quellcode:
Die CallBack-Prozedur:

//=========== Prozedur NotifiCallback ==========================================
procedure NotifiCallback(pNotifData:PWLAN_NOTIFICATION_DATA; pContext:PVOID); stdcall;
var
   Source:DWord;
begin
   if pNotifData<>nil then
   begin
      Source:=pNotifData.NotificationSource;
      if (Source and WLAN_NOTIFICATION_SOURCE_ALL) > 0 then
      begin
         case pNotifData^.NotificationCode of
            wlan_notification_acm_scan_complete:
               begin
                  SetEvent(THandle(pContext^));
               end;
         end; // case pNotifData^.NotificationCode of
      end; // if pNotifData^.NotificationSource of
   end // if pNotifData<>nil
end; // function NotifiCallback


Die Funktion WlanScan:
//=========== Funktion WlanScan ================================================
function TWlanClass.WlanScan(InterfaceIndex:integer): DWORD;
var
   mGUID:TGUID;
   ergebnis:DWORD; hScanCompleteEvent: THandle;
   hClientHandle:THandle; dwNegotiatedVersion: WORD;
begin
    ergebnis:=WlanOpenHandle(WLAN_API_VERSION,nil,@dwNegotiatedVersion,@hClientHandle);
    mGUID:=InterfaceInfoArr[InterfaceIndex].InterfaceGuid;

    hScanCompleteEvent:=CreateEvent(nil, False, False, nil);

    result:=WlanRegisterNotification(hClientHandle,WLAN_NOTIFICATION_SOURCE_ALL
       ,true,@NotifiCallback,@hScanCompleteEvent,nil,@dwPrevNotifSource);

    ergebnis:=nduWlanAPI.WlanScan(hClientHandle,@mGUID,nil,nil,nil);

    result:=ergebnis;

    if ergebnis=ERROR_SUCCESS then
    begin
       WaitForSingleObject(hScanCompleteEvent, 20*1000);
       //ShowMessage('Scan complete.');
    end;

    // UnregisterNotification
    WlanRegisterNotification(hClientHandle,WLAN_NOTIFICATION_SOURCE_NONE
       ,true,nil,nil,nil,@dwPrevNotifSource);

    WlanCloseHandle(hClientHandle,nil);

end; // function WlanScan(InterfaceIndex:integer): boolean;

Ich bin dabei eine ActiveX-DLL für Wlan zu erstellen zur Nutzung in weiteren
Programmiersprachen (z. B. Visual Basic, Delphi).
Daher habe ich das bisher in einer Klasse.

Grüße jogging_cat
  Mit Zitat antworten Zitat