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









share|improve this question
























  • 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















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









share|improve this question
























  • 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













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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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
















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












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






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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






    share|improve this answer

























      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






      share|improve this answer























        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






        share|improve this answer












        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 at 6:32









        Baron

        322




        322






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine