AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi WlanRegisterNotification Problem
Thema durchsuchen
Ansicht
Themen-Optionen

WlanRegisterNotification Problem

Offene Frage von "Pichel"
Ein Thema von nitschchedu · begonnen am 5. Nov 2007 · letzter Beitrag vom 21. Sep 2009
Antwort Antwort
Seite 1 von 2  1 2      
nitschchedu

Registriert seit: 24. Mär 2006
300 Beiträge
 
Delphi 7 Professional
 
#1

WlanRegisterNotification Problem

  Alt 5. Nov 2007, 20:54
Hallo Leute,
wie sicherlich schon einige mitbekommen und auch mit gewirkt haben, an der WLanAPI, ist mal wieder ein Probelm aufgetreten.
Also wie im Titel schon erwähnt geht es um die WlanRegisterNotification.

Volgendes habe ich gemacht.

Delphi-Quellcode:

procedure WLanNotifyProc(pNotifyData: Pndu_WLAN_NOTIFICATION_DATA;
   pContext: PVOID);
begin
   if pNotifyData.NotificationSource = NDU_WLAN_NOTIFICATION_SOURCE_ACM then
  begin
     if Tndu_WLAN_NOTIFICATION_ACM(pNotifyData.NotificationCode) = wlan_notification_acm_scan_complete then
    begin
       SetEvent(THandle(pContext));
    end;
  end;
end;


procedure .... ;
var
  hClient: THandle;
  hScanCompleteEvent: THandle;
  back: DWORD;
begin
  .....
  hScanCompleteEvent := CreateEvent(nil, False, False, nil);
  
  back := WlanRegisterNotification(hClient, NDU_WLAN_NOTIFICATION_SOURCE_ALL,
     True, @WLanNotifyProc, @hScanCompleteEvent, nil, nil);

  ...
  
  if back <> ERROR_SUCCESS then
  begin
     Memo1.Lines.Add('Fehler bei WlanRegisterNotification');
     Exit;
  end;

  back := WlanScan(hClient, @pInterface.InterfaceInfo[0].InterfaceGuid,
     nil, nil, nil);

  if back <> ERROR_SUCCESS then
  begin
     Memo1.Lines.Add('Fehler bei WlanScan');
     Exit;
  end;

  WaitForSingleObject(hScanCompleteEvent, INFINITE);

  ....
end;
So das Problem:
In der Procedure "WLanNotifyProc" wo ich auch schön reinspringe, bekomme ich in der Variable "pNotifyData"
nur Müll und somit komme ich bei "WaitForSingleObject" nicht weiter .

Ich hoffe es kann mir jemand weiter Helfen.
PS: Habe unten noch ein Bild mit dem was im Speicher ist angehangen.
Miniaturansicht angehängter Grafiken
wlan_134.jpg  
Programmieren ..... .
  Mit Zitat antworten Zitat
nitschchedu

Registriert seit: 24. Mär 2006
300 Beiträge
 
Delphi 7 Professional
 
#2

Re: WlanRegisterNotification Problem

  Alt 6. Nov 2007, 19:54
Ok da keiner Antwortet will ich meine Frage anders stellen.
Kann ich einfach eine Procedure Deklarieren und dann mit @name auf PVoid übergeben ?

So ist es in C++ Deklariert.

Code:
// the callback function for notifications
typedef VOID (WINAPI *WLAN_NOTIFICATION_CALLBACK) (PWLAN_NOTIFICATION_DATA, PVOID);


....

DWORD WINAPI
WlanRegisterNotification(
    __in HANDLE hClientHandle,
    __in DWORD dwNotifSource,
    __in BOOL bIgnoreDuplicate,
    __in_opt WLAN_NOTIFICATION_CALLBACK funcCallback,
    __in_opt PVOID pCallbackContext,
    __reserved PVOID pReserved,
    __out_opt PDWORD pdwPrevNotifSource
);
Und meine :

Delphi-Quellcode:
PVOID                     = Pointer;            ///C PVoid
Tndu_WLAN_NOTIFICATION_CALLBACK   = PVOID;

function WlanRegisterNotification(hClientHandle: Handle;
     dwNotifSource: DWORD; bIgnoreDuplicate: Bool;
    funcCallback: Tndu_WLAN_NOTIFICATION_CALLBACK;
    pCallbackContext: PVOID; pReserved: PVOID;
    pdwPrevNotifSource: PDWORD): DWORD; stdcall;
Programmieren ..... .
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#3

Re: WlanRegisterNotification Problem

  Alt 6. Nov 2007, 23:40
Na endlich etwas womit man eine Antwort definieren kann ohne sich erstmal die MSDN installieren zu müssen...

Warum definierst du dir keinen Callback Prototypen?

Delphi-Quellcode:
type
    // Deklaration von WLAN_NOTIFICATION_DATA fehlt noch...
    // durch das Var entfällt das Pxxx
  WLAN_NOTIFICATION_CALLBACK = procedure(var WLAN_Notification_Data: ???; pCallbackContext: Pointer);

function WLanRegisterNotification(hClientHandle: THandle; dwNotifySource: LongWord; bIgnoreDuplicate: LongBool;
  FuncCallBack: WLAN_NOTIFICATION_CALLBACK; pCallbackContext: Pointer; pReserved: Pointer; var pdwPrevNotifySource: LongWord): LongWord; stdcall;
  Mit Zitat antworten Zitat
Benutzerbild von negaH
negaH

Registriert seit: 25. Jun 2003
Ort: Thüringen
2.950 Beiträge
 
#4

Re: WlanRegisterNotification Problem

  Alt 7. Nov 2007, 05:58
typedef void WINAPI*...

dh. deine Callback sollte wohl stdcall sein ?

Delphi-Quellcode:
procedure WLanNotifyProc(pNotifyData: Pndu_WLAN_NOTIFICATION_DATA; pContext: PVOID); stdcall; // <--
begin
.... bla bla
end;
Gruß Hagen
  Mit Zitat antworten Zitat
nitschchedu

Registriert seit: 24. Mär 2006
300 Beiträge
 
Delphi 7 Professional
 
#5

Re: WlanRegisterNotification Problem

  Alt 7. Nov 2007, 07:18
Omg es geht auf das stdcall wäre ich wohl nie gekommen .... Danke
Und das mit dem Callback Prototypen ist auch keine schlechte Idee !

Edit: Und schon gibt es ein neues Problem

Ich komme bei WaitForSingleObject(hScanCompleteEvent, INFINITE); nicht weiter.
Programmieren ..... .
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#6

Re: WlanRegisterNotification Problem

  Alt 7. Nov 2007, 09:29
Zitat von nitschchedu:
Ich komme bei WaitForSingleObject(hScanCompleteEvent, INFINITE); nicht weiter.
Das heisst?
  Mit Zitat antworten Zitat
nitschchedu

Registriert seit: 24. Mär 2006
300 Beiträge
 
Delphi 7 Professional
 
#7

Re: WlanRegisterNotification Problem

  Alt 7. Nov 2007, 09:45
Also beim Debugen komme ich zu den Punkt WaitForSingleObject(hScanCompleteEvent, INFINITE); dann sage ich geh weiter (damit muss er dort anhalten) ... springe nach einer weile in
Delphi-Quellcode:
procedure WLanNotifyProc(pNotifyData: Pndu_WLAN_NOTIFICATION_DATA;
   pContext: PVOID);
wo ich wieder sage
SetEvent(THandle(pContext)); damit er bei
WaitForSingleObject(hScanCompleteEvent, INFINITE); weiter geht ... aber nix passiert

Weil er muss an der der Stelle warten bis das Scannen fertig ist und dann darf er weiter gehen.
Programmieren ..... .
  Mit Zitat antworten Zitat
Benutzerbild von sirius
sirius

Registriert seit: 3. Jan 2007
Ort: Dresden
3.443 Beiträge
 
Delphi 7 Enterprise
 
#8

Re: WlanRegisterNotification Problem

  Alt 7. Nov 2007, 09:53
Wird WlanRegisterNotification in einem eigenen Thread ausgeführt?
Dieser Beitrag ist für Jugendliche unter 18 Jahren nicht geeignet.
  Mit Zitat antworten Zitat
nitschchedu

Registriert seit: 24. Mär 2006
300 Beiträge
 
Delphi 7 Professional
 
#9

Re: WlanRegisterNotification Problem

  Alt 7. Nov 2007, 09:55
Jop und zwar von der WlanAPI selbst ... also ich könnte ich nur die Procedure REgistrieren und wenn jemand anders Scant springt er bei mir rein.
Programmieren ..... .
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#10

Re: WlanRegisterNotification Problem

  Alt 7. Nov 2007, 09:56
Das Problem ist einfach nur, dass das Handle von SetEvent() nicht stimmt. Der Result wird dir das bestätigen.

Du übergibst beim Aufruf ein @Handle, also die Adresse der Variable mit dem handle und im CallBack nutzt du den Pointer direkt als Handle.

Also entweder beim Aufruf Pointer(Handle) und Callback so lassen oder im CallBack PHandle(pContext)^ nutzen.
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:22 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz