Disconnect??

Aug 27, 2008 at 9:39 PM
First... Great API!!!! 

I cannot find the WlanDisconnect() function.  Was this left out or am I overlooking it??  Please point me in the direction of the disconnect function and a simple example of how to call it from C#.

Thanks for your help....
Wayne
Feb 20, 2009 at 1:51 PM
Did you find a way to disconnect? I'm looking for disconnecting also.
thanks for your help.

carole


Feb 21, 2009 at 2:12 AM
Edited Feb 21, 2009 at 2:15 AM
The event handler in WlanClient.WlanInterface.WlanConnectionNotification

It will alert you of a disconnect.

Example code:
This is in my static void main (for a console app)
WlanClient client = new WlanClient();
            foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
            {
                //Add the event to track when the wireless connection changes
                wlanIface.WlanConnectionNotification += new WlanClient.WlanInterface.WlanConnectionNotificationEventHandler(wlanIface_WlanConnectionNotification);
}
This is my event.  It will currently write to the console the notification code, one of which is Disconnect.

        static void wlanIface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
        {
            Console.WriteLine(notifyData.NotificationCode);
            //Console.WriteLine("{0} to {1} with quality level {2}",connNotifyData.wlanConnectionMode, connNotifyData.profileName, "-");
        }

Hope that helps.

After reading the question again - i realized you wanted to actually disconnect from the network... Sorry I didn't answer that question. I'll keep looking around though.
Feb 23, 2009 at 9:06 AM
yes, thanks a lot!

carole

Apr 24, 2009 at 11:28 AM

On Interop.cs you should add :

        [DllImport("wlanapi.dll")]
        public static extern int WlanDisconnect(
            [In] IntPtr clientHandle,
            [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid,
            IntPtr pReserved);

And on WlanApi:

            /// <summary>
            /// Disconnects to a network
            /// </summary>
            public void Disconnect()
            {

                Wlan.ThrowIfError(
                    Wlan.WlanDisconnect(client.clientHandle, info.interfaceGuid, IntPtr.Zero));
            }

With these you'll be able to call the Disconnect method!! ;)

Apr 27, 2009 at 4:19 AM

Thank you

Wayne C. Kessler

w.kessler3@verizon.net

cell: (941) 807-6208

From: jaumec [mailto:notifications@codeplex.com]
Sent: Friday, April 24, 2009 6:28 AM
To: w.kessler3@verizon.net
Subject: Re: Disconnect?? [managedwifi:34405]

From: jaumec

On Interop.cs you should add :

[DllImport("wlanapi.dll")]
public static extern int WlanDisconnect(
[In] IntPtr clientHandle,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid,
IntPtr pReserved);

And on WlanApi:

/// <summary>
/// Disconnects to a network
/// </summary>
public void Disconnect()
{

Wlan.ThrowIfError(
Wlan.WlanDisconnect(client.clientHandle, info.interfaceGuid, IntPtr.Zero));
}

With these you'll be able to call the Disconnect method!! ;)

Read the full discussion online.

To add a post to this discussion, reply to this email (managedwifi@discussions.codeplex.com)

To start a new discussion for this project, email managedwifi@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

May 1, 2009 at 6:15 AM
Edited May 1, 2009 at 6:51 AM
Hi guy can any one help in reading or connceting available network and reading all the systems in that network ......
as you guys are discussing about disconnecting wireless network ,hope you guys know how to connect to the available network.. plz help me out...
if i use the connect method i am getting this error "The network connection profile is corrupted"
i am using this code to connect is this right..... and the mac and key is required to connect give me some idea ...
 string profileName = SelectedItem.Text;
 string mac = "52544131303235572D454137443638";
            string key = "hello";
            string profileXml = string.Format("<?xml version=\"2.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><hex>{1}</hex><name>{0}</name></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>open</authentication><encryption>WEP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>networkKey</keyType><protected>false</protected><keyMaterial>{2}</keyMaterial></sharedKey><keyIndex>0</keyIndex></security></MSM></WLANProfile>", profileName, mac, key);
            wlanIface.SetProfile(Wlan.WlanProfileFlags.AllUser, profileXml, true);
            wlanIface.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Infrastructure, profileName);

thank you