Windows XP 中从 wlanapi.dll 进行 WlanConnect 失败
我正在创建一个能够自动连接到无线网络的程序。为此,我使用一个名为 ManagedWifi 的库,它使用库“wlanapi.dll”。当我尝试在 Windows Vista 上使用该代码时,一切正常,但当我在 Windows XP 上使用它时,它会失败。我检查过它是否安装了 Service Pack 3,并且“wlanapi.dll”位于 Windows/system32 中。问题是当 ManagedWifi 调用此方法时:
[DllImport("wlanapi.dll")]
public static extern int WlanConnect(
[In] IntPtr clientHandle,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid,
[In] ref WlanConnectionParameters connectionParameters,
IntPtr pReserved);
它会抛出错误 System.ComponentModel.Win32Exception:找不到元素。但是,如果该库正确位于 system32 中,为什么会抛出此错误?为什么只在 Windows XP 中而不在 Vista 中?
非常感谢大家
编辑:我已经检查了 Vista 和 XP 这两个文件版本,我发现它们是不同的(XP:5.1,Vista:6.0),但我已将 Vista 的版本复制到XP和我还是有同样的问题
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
已解决
问题是,当网络是 adhoc 网络时,Windows XP 会在名称中添加“-adhoc”后缀。当我尝试连接它时,它没有找到“xxx”网络
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
使用:
您必须首先创建配置文件,未找到元素表示您尝试连接的配置文件不可用
Using :
You have to create the profile first, Element not found says that the profile which you are trying to connect is not available