Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-11

Wireless configuration in Windows

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jürgen Hestermann

I am trying to access the Wireless interface of the Windows API. It seems that there is no support for these functions in Free Pascal so I defined them myself and accessed them via "Loadlibrary". But WlanOpenHandle always results in error 87 (invalid parameter). I defined:

-----------------------------------------------------------------------
type WlanOpenHandleTyp = function(ClientVersion : DWord;
                                  Reserved : Pointer;
                              var NegotiatedVersion : DWord;
                              var ClientHandle : Hwnd) : DWord;
-----------------------------------------------------------------------

but also tried a different definitions of the first two parameters with CONST.

I then coded:

-----------------------------------------------------------------------
Var LibHandle       : THandle;
    H               : Hwnd;
    WlanOpenHandle  : WlanOpenHandleTyp;
begin
LibHandle := Windows.LoadLibrary('wlanapi.dll');
if LibHandle0 then
   begin
   WlanOpenHandle := WlanOpenHandleTyp(GetProcAddress(LibHandle,'WlanOpenHandle'));
   if WlanOpenHandlenil then
      begin
      j := WlanOpenHandle(1,nil,i,H);
      if j=Error_Success then ....
-----------------------------------------------------------------------

at this point j is 87 (should be 0). Anybody who has an idea why WlanOpenHandle is reporting this error?

Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
Felipe Monteiro de Carvalho
to Jürgen Hestermann
"Jürgen Hestermann" wrote 5 lines
----------------------------------------------------------------------- type WlanOpenHandleTyp = function(ClientVersion : DWord;                                  Reserved : Pointer;                              var NegotiatedVersion : DWord;                              var ClientHandle : Hwnd) : DWord;

It looks like you forgot to add the calling convention: stdcall

Felipe Monteiro de Carvalho
Leonardo M. Ramé
to Jürgen Hestermann: I am trying to access the Wireless interface of the Windows API. It seems that there is…

----- Original Message -----

Show quoted text 45 lines
From: ""Jürgen Hestermann"" To: Cc: Sent: Tuesday, November 29, 2011 11:56 AM Subject: [fpc-pascal] Wireless configuration in Windows I am trying to access the Wireless interface of the Windows API. It seems that there is no support for these functions in Free Pascal so I defined them myself and accessed them via "Loadlibrary". But WlanOpenHandle always results in error 87 (invalid parameter). I defined: ----------------------------------------------------------------------- type WlanOpenHandleTyp = function(ClientVersion : DWord;                                   Reserved : Pointer;                               var NegotiatedVersion : DWord;                               var ClientHandle : Hwnd) : DWord; ----------------------------------------------------------------------- but also tried a different definitions of the first two parameters with CONST. I then coded: ----------------------------------------------------------------------- Var LibHandle      : THandle;     H              : Hwnd;     WlanOpenHandle  : WlanOpenHandleTyp; begin LibHandle := Windows.LoadLibrary('wlanapi.dll'); if LibHandle0 then   begin   WlanOpenHandle := WlanOpenHandleTyp(GetProcAddress(LibHandle,'WlanOpenHandle'));   if WlanOpenHandlenil then       begin       j := WlanOpenHandle(1,nil,i,H);       if j=Error_Success then .... ----------------------------------------------------------------------- at this point j is 87 (should be 0). Anybody who has an idea why WlanOpenHandle is reporting this error? -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

Didn't tested, but can you try this?:

Original function:
DWORD WINAPI WlanOpenHandle( __in        DWORD dwClientVersion, __reserved  PVOID pReserved, __out       PDWORD pdwNegotiatedVersion, __out       PHANDLE phClientHandle );

Pascal conversion:
type WlanOpenHandleTyp = function(ClientVersion : DWord;
                              Reserved : Pointer;
                              out NegotiatedVersion : DWord;
                              out ClientHandle : Cardinal) : DWord;

--  
Leonardo M. Ramé
http://leonardorame.blogspot.com

Jürgen Hestermann
to Felipe Monteiro de Carvalho: On Tue, Nov 29, 2011 at 3:56 PM, "Jürgen Hestermann" It looks like you forgot to add the…
Show quoted text 6 lines
> type WlanOpenHandleTyp = function(ClientVersion : DWord; > Reserved : Pointer; > var NegotiatedVersion : DWord; > var ClientHandle : Hwnd) : DWord; > It looks like you forgot to add the calling convention: stdcal

Yes, now that you tell me, it seems to be the problem. I can't test today anymore but will do tomorrow.
Thanks for reminding me. I was completeley stuck.