Question

I am creating a program which will be able to connect automatically to a wireless network. For doing that, I am using a library called ManagedWifi, which uses the library "wlanapi.dll". When I try to use the code on Windows Vista, everything is fine, but when I use it on Windows XP it fails. I have checked that it has Service Pack 3 installed, and "wlanapi.dll" is located in Windows/system32. The problem is when ManagedWifi calls this method:

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

It throws an error System.ComponentModel.Win32Exception: Element not found. But, if the library is correctly located in system32, why does it throw this error? And why only in Windows XP and not in Vista?

Thank you very much to everyone

EDIT: I have checked boith file versions, Vista and XP, and I've seen they are different (XP: 5.1, Vista: 6.0) but I have copied Vista's version to XP and I still have the same problem

Was it helpful?

Solution

Solved

The problem is that Windows XP, when the network is an adhoc network, adds the "-adhoc" sufix to the name. When I was trying to connect to it, it didn't find the "xxx" network

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top