Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6949553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:58:11+00:00 2026-05-27T13:58:11+00:00

I’m new in C++ and I’m looking for an code example how to write

  • 0

I’m new in C++ and I’m looking for an code example how to write the enumeration to set in GetNetworkConnections().
the documentation have no an code example how do it.

my code:

#include "stdafx.h"
#include "windows.h"
#include "Netlistmgr.h"

int _tmain(int argc, _TCHAR* argv[])
{
    HRESULT hResult = INetwork::GetNetworkConnections( ?? );
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:58:11+00:00Added an answer on May 27, 2026 at 1:58 pm

    First things first! Your sample code is already wrong. System headers are included using a different syntax than headers in your project.

    Headers in your project are included with quotation marks around the name of the header, like so:

    #include "stdafx.h"
    

    System headers (like windows.h) are included using angle brackets, like so:

    #include <windows.h>
    #include <netlistmgr.h>
    

    Make sure that you get that correct!


    The prototype for the function given in the documentation indicates that it accepts a single parameter that is a pointer to a pointer:

    HRESULT STDMETHODCALLTYPE GetNetworkConnections(
      [out]  IEnumNetworkConnections **ppEnum
    );
    

    I assume you know the C++ language well enough to know what that means. The function is going to modify a pointer variable, and the only way that it can modify something is for it to work on a pointer to that object. So you end up with double pointers, because you’re modifying a pointer.

    Again, the documentation gives you a clue as to how it works when it describes the parameters:

    ppEnum [out]

    Pointer to a pointer that receives an IEnumNetworkConnections interface instance that enumerates all network connections on the machine.

    You call it by declaring a pointer variable of the correct type, and then passing the address of that variable into the function.

    The function returns an HRESULT value, which is a common way that COM functions indicate success or failure. You can use the SUCCEEDED macro to test whether the function call was successful.

    That’s how you call the GetNetworkConnections function. But uh-oh, I just mentioned COM in that last paragraph. Sure enough, this is actually a COM API, provided by the INetworkListManager interface. So it gets a whole lot more complicated than just calling this single function.

    GetNetworkConnections is not a static method, so it can’t be called directly from the interface. You have to instantiate an object instance that implements that interface, and then call the member method on that object. Thus, you need to initialize COM first in your application, and then create the CLSID_NetworkListManager COM object.

    If you go a level up in the documentation, away from the API “Reference” and to a page “About” the API, you’ll generally see some sample code. For example, here.

    Unfortunately, this won’t tell or show you everything you need to know about COM. It’s going to assume you already know how to do COM programming. And you should. Look up some links for more information; I can’t write a full tutorial here, and there are lots of dark corners and alleys just waiting to trip you up.

    Alas, working sample code for the single function that you’re attempting to call:

    #include "stdafx.h"       // include your app's precompiled header
    #include <windows.h>      // include the base Windows header
    #include <ObjBase.h>      // include the base COM header
    #include <netlistmgr.h>
    
    // Instruct linker to link to the required COM libraries
    #pragma comment(lib, "ole32.lib")
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        // Initialize COM.
       if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
       {
          // Initializing COM was successful, so declare a pointer
          // to an INetworkListManager object.
          INetworkListManager* pNetworkListManager; 
    
          // Create an instance of the CLSID_NetworkListManger COM object,
          // using the SUCCEEDED macro to test for success.
          if (SUCCEEDED(CoCreateInstance(CLSID_NetworkListManager, NULL,
                                         CLSCTX_ALL, IID_INetworkListManager,
                                         (LPVOID*)&pNetworkListManager)))
          {
             // Creating the object was successful.
             //
             // Declare your pointer to an IEnumNetworkConnections object,
             // which the function call will set.
             IEnumNetworkConnections* pEnum;
    
             // Call the function, passing in the address of your pointer,
             // and test for success using the SUCCEEDED macro.
             if (SUCCEEDED(pNetworkListManager->GetNetworkConnections(&pEnum)))
             {
                   // The function call succeeded.
                   // 
                   // pEnum contains a valid pointer to an IEnumNetworkConnections
                   // object, which you can now use.
                   //
                   // ...
             }
          }
       }
    
       // Uninitialize COM.
       // (This should be called on application shutdown.)
       CoUninitialize();
    
       return 0;
    }
    

    (Yes, COM code is often ugly. You can omit the error-checking if you’re brave, but I don’t recommend it.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.