简体   繁体   English

WNetAddConnection不会失败,但是不起作用

[英]WNetAddConnection doesn't fail but doesn't work

My calls to WlanConnect connects fine to the AP. 我对WlanConnect的呼叫可以很好地连接到AP。 But if I call WNetAddConnectionA or WNetAddConnection2A, they both return 0 (NO_ERROR), but they don't connect to the AP. 但是,如果我调用WNetAddConnectionA或WNetAddConnection2A,它们都返回0(NO_ERROR),但它们没有连接到AP。 What's wrong? 怎么了?

EDIT: // added code 编辑://添加代码

NETRESOURCE netResource;
    netResource.dwType = RESOURCETYPE_ANY;
    netResource.lpLocalName = NULL;
    netResource.lpRemoteName = (char *)"\\\\xxx.xxx.xxx.xxx";
    netResource.lpProvider = NULL;
    std::cout << WNetAddConnection2A(&netResource, "password", NULL, 
CONNECT_UPDATE_PROFILE); // prints 0

As the document says, when you set CONNECT_UPDATE_PROFILE flag, the network resource connection should be remembered. 文档所述 ,当您设置CONNECT_UPDATE_PROFILE标志时,应该记住网络资源连接。

The operating system remembers only successful connections that redirect local devices. 操作系统仅记住重定向本地设备的成功连接。 It does not remember connections that are unsuccessful or deviceless connections. 它不记得连接失败或无设备的连接。 (A deviceless connection occurs when the lpLocalName member is NULL or points to an empty string.) (当lpLocalName成员为NULL或指向空字符串时,将发生无设备连接。)

Have you tried to use the proper username without NULL? 您是否尝试使用不带NULL的正确用户名?

Best Regards, Baron 最好的问候,男爵

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM