![]() |
WlanRegisterNotification Problem
Liste der Anhänge anzeigen (Anzahl: 1)
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:
So das Problem: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; 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. |
Re: WlanRegisterNotification Problem
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:
Und meine :
// 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 );
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; |
Re: WlanRegisterNotification Problem
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; |
Re: WlanRegisterNotification Problem
typedef void WINAPI*...
dh. deine Callback sollte wohl stdcall sein ?
Delphi-Quellcode:
Gruß Hagen
procedure WLanNotifyProc(pNotifyData: Pndu_WLAN_NOTIFICATION_DATA; pContext: PVOID); stdcall; // <--
begin .... bla bla end; |
Re: WlanRegisterNotification Problem
Omg es geht auf das stdcall wäre ich wohl nie gekommen .... Danke :thumb:
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. |
Re: WlanRegisterNotification Problem
Zitat:
|
Re: WlanRegisterNotification Problem
Also beim Debugen komme ich zu den Punkt
Delphi-Quellcode:
dann sage ich geh weiter (damit muss er dort anhalten) ... springe nach einer weile in
WaitForSingleObject(hScanCompleteEvent, INFINITE);
Delphi-Quellcode:
wo ich wieder sage
procedure WLanNotifyProc(pNotifyData: Pndu_WLAN_NOTIFICATION_DATA;
pContext: PVOID);
Delphi-Quellcode:
damit er bei
SetEvent(THandle(pContext));
Delphi-Quellcode:
weiter geht ... aber nix passiert :-(
WaitForSingleObject(hScanCompleteEvent, INFINITE);
Weil er muss an der der Stelle warten bis das Scannen fertig ist und dann darf er weiter gehen. |
Re: WlanRegisterNotification Problem
Wird WlanRegisterNotification in einem eigenen Thread ausgeführt?
|
Re: WlanRegisterNotification Problem
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.
|
Re: WlanRegisterNotification Problem
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. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:11 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz