[fpc-pascal] Wireless configuration in Windows

Leonardo M. Ramé martinrame at yahoo.com
Tue Nov 29 16:03:11 CET 2011


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

> From: ""Jürgen Hestermann"" <Juergen.Hestermann at gmx.de>
> To: fpc-pascal at lists.freepascal.org
> 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 LibHandle<>0 then
>    begin
>    WlanOpenHandle := 
> WlanOpenHandleTyp(GetProcAddress(LibHandle,'WlanOpenHandle'));
>    if WlanOpenHandle<>nil 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



More information about the fpc-pascal mailing list