WNetAddConnection doesn't fail but doesn't work
up vote
2
down vote
favorite
My calls to WlanConnect connects fine to the AP. But if I call WNetAddConnectionA or WNetAddConnection2A, they both return 0 (NO_ERROR), but they don't connect to the 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
c++ winapi networking
|
show 8 more comments
up vote
2
down vote
favorite
My calls to WlanConnect connects fine to the AP. But if I call WNetAddConnectionA or WNetAddConnection2A, they both return 0 (NO_ERROR), but they don't connect to the 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
c++ winapi networking
How will we know "what's wrong" if you don't provide the code...? It should be noted that your usage of the function affects it... So if you don't show us the code, then, there is no way we can help you...
– Ruks
Nov 11 at 3:53
Look at the documentation of this function... It clearly states that "This function is provided only for compatibility with 16-bit versions of Windows. Other Windows-based applications should call the WNetAddConnection2 or the WNetAddConnection3 function."... You shouldn't use this function anymore...
– Ruks
Nov 11 at 3:58
But I also tried with WNetAddConnection2 and it didn't work
– user2000
Nov 11 at 4:00
Look at the example here... Have you usedWNetAddConnection2()
properly?
– Ruks
Nov 11 at 4:01
I'm confused about this lpRemoteName thing. Why does it need 4 backslashes, and what exactly is it?
– user2000
Nov 11 at 4:04
|
show 8 more comments
up vote
2
down vote
favorite
up vote
2
down vote
favorite
My calls to WlanConnect connects fine to the AP. But if I call WNetAddConnectionA or WNetAddConnection2A, they both return 0 (NO_ERROR), but they don't connect to the 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
c++ winapi networking
My calls to WlanConnect connects fine to the AP. But if I call WNetAddConnectionA or WNetAddConnection2A, they both return 0 (NO_ERROR), but they don't connect to the 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
c++ winapi networking
c++ winapi networking
edited Nov 11 at 4:02
asked Nov 11 at 3:49
user2000
112
112
How will we know "what's wrong" if you don't provide the code...? It should be noted that your usage of the function affects it... So if you don't show us the code, then, there is no way we can help you...
– Ruks
Nov 11 at 3:53
Look at the documentation of this function... It clearly states that "This function is provided only for compatibility with 16-bit versions of Windows. Other Windows-based applications should call the WNetAddConnection2 or the WNetAddConnection3 function."... You shouldn't use this function anymore...
– Ruks
Nov 11 at 3:58
But I also tried with WNetAddConnection2 and it didn't work
– user2000
Nov 11 at 4:00
Look at the example here... Have you usedWNetAddConnection2()
properly?
– Ruks
Nov 11 at 4:01
I'm confused about this lpRemoteName thing. Why does it need 4 backslashes, and what exactly is it?
– user2000
Nov 11 at 4:04
|
show 8 more comments
How will we know "what's wrong" if you don't provide the code...? It should be noted that your usage of the function affects it... So if you don't show us the code, then, there is no way we can help you...
– Ruks
Nov 11 at 3:53
Look at the documentation of this function... It clearly states that "This function is provided only for compatibility with 16-bit versions of Windows. Other Windows-based applications should call the WNetAddConnection2 or the WNetAddConnection3 function."... You shouldn't use this function anymore...
– Ruks
Nov 11 at 3:58
But I also tried with WNetAddConnection2 and it didn't work
– user2000
Nov 11 at 4:00
Look at the example here... Have you usedWNetAddConnection2()
properly?
– Ruks
Nov 11 at 4:01
I'm confused about this lpRemoteName thing. Why does it need 4 backslashes, and what exactly is it?
– user2000
Nov 11 at 4:04
How will we know "what's wrong" if you don't provide the code...? It should be noted that your usage of the function affects it... So if you don't show us the code, then, there is no way we can help you...
– Ruks
Nov 11 at 3:53
How will we know "what's wrong" if you don't provide the code...? It should be noted that your usage of the function affects it... So if you don't show us the code, then, there is no way we can help you...
– Ruks
Nov 11 at 3:53
Look at the documentation of this function... It clearly states that "This function is provided only for compatibility with 16-bit versions of Windows. Other Windows-based applications should call the WNetAddConnection2 or the WNetAddConnection3 function."... You shouldn't use this function anymore...
– Ruks
Nov 11 at 3:58
Look at the documentation of this function... It clearly states that "This function is provided only for compatibility with 16-bit versions of Windows. Other Windows-based applications should call the WNetAddConnection2 or the WNetAddConnection3 function."... You shouldn't use this function anymore...
– Ruks
Nov 11 at 3:58
But I also tried with WNetAddConnection2 and it didn't work
– user2000
Nov 11 at 4:00
But I also tried with WNetAddConnection2 and it didn't work
– user2000
Nov 11 at 4:00
Look at the example here... Have you used
WNetAddConnection2()
properly?– Ruks
Nov 11 at 4:01
Look at the example here... Have you used
WNetAddConnection2()
properly?– Ruks
Nov 11 at 4:01
I'm confused about this lpRemoteName thing. Why does it need 4 backslashes, and what exactly is it?
– user2000
Nov 11 at 4:04
I'm confused about this lpRemoteName thing. Why does it need 4 backslashes, and what exactly is it?
– user2000
Nov 11 at 4:04
|
show 8 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
As the document says, when you set CONNECT_UPDATE_PROFILE flag, the network resource connection should be remembered.
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.)
Have you tried to use the proper username without NULL?
Best Regards,
Baron
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As the document says, when you set CONNECT_UPDATE_PROFILE flag, the network resource connection should be remembered.
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.)
Have you tried to use the proper username without NULL?
Best Regards,
Baron
add a comment |
up vote
0
down vote
As the document says, when you set CONNECT_UPDATE_PROFILE flag, the network resource connection should be remembered.
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.)
Have you tried to use the proper username without NULL?
Best Regards,
Baron
add a comment |
up vote
0
down vote
up vote
0
down vote
As the document says, when you set CONNECT_UPDATE_PROFILE flag, the network resource connection should be remembered.
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.)
Have you tried to use the proper username without NULL?
Best Regards,
Baron
As the document says, when you set CONNECT_UPDATE_PROFILE flag, the network resource connection should be remembered.
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.)
Have you tried to use the proper username without NULL?
Best Regards,
Baron
answered Nov 14 at 6:32
Baron
322
322
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245685%2fwnetaddconnection-doesnt-fail-but-doesnt-work%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How will we know "what's wrong" if you don't provide the code...? It should be noted that your usage of the function affects it... So if you don't show us the code, then, there is no way we can help you...
– Ruks
Nov 11 at 3:53
Look at the documentation of this function... It clearly states that "This function is provided only for compatibility with 16-bit versions of Windows. Other Windows-based applications should call the WNetAddConnection2 or the WNetAddConnection3 function."... You shouldn't use this function anymore...
– Ruks
Nov 11 at 3:58
But I also tried with WNetAddConnection2 and it didn't work
– user2000
Nov 11 at 4:00
Look at the example here... Have you used
WNetAddConnection2()
properly?– Ruks
Nov 11 at 4:01
I'm confused about this lpRemoteName thing. Why does it need 4 backslashes, and what exactly is it?
– user2000
Nov 11 at 4:04