"Nighthawk" <bi******@hotmail.comwrote in message
news:E8**********************************@microsof t.com...
>I am trying to use NativeWifi. I tried putting
"Using NativeWifi" in my C# code but it throws error right there.
I think I will need to add reference to my application. I don't know which
dll i need to import.
I have installed Windows SDK. Tried searching for Nativewifi.dll but could
not find it. There is a file Nativewifi.hxs but I don't know what that is
or
how to use it.
Please help me get started.
thanks
The native Wifi API's are a set op native code libary API's NOT a set of
managed API's, so you can't use "using ..." .
To use native API's from C#, you'll need to use PInvoke, that means, you
will need to declare all API's, enums and native structures as managed
functions and types.
// WlanApi function declarations
[DllImport("Wlanapi.dll")]
static extern int WlanOpenHandle( int clientVersion, IntPtr reserved, out
int negotiatedVersion, out IntPtr clientHandle);
// usage
....
int clientVersion = 1; // XP SP2
int negotiatedVersion;
IntPtr clientHandle;
int error = WlanOpenHandle(clientVersion, IntPtr.Zero, out
negotiatedVersion, out clientHandle);
if(error != 0)
{
// function failed... inspect error number and throw
}
else
{
// use valid clientHandle in the other wlan API's, like WlanGetProfile,
WlanConnect etc....
....
Willy.