CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006
    Location
    Minneapolis, Minnesota
    Posts
    33

    Question Linking issue with NcFreeNetconProperties

    Hey folks,

    I got a real simple question: I can't link with: NcFreeNetconProperties.

    VS2005's linker returns:error LNK2019: unresolved external symbol _NcFreeNetconProperties@4

    I need to use this call because I earlier involked:
    GetProperties(NETCON_PROPERTIES **ppProps)
    Last edited by werpa; February 2nd, 2007 at 02:44 PM. Reason: Preview didn't show bizarre characters so had to edit them out.

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: Linking question on NcFreeNetconProperties(NETCON_PROPERTIES*);

    Accroding to the documentation you shouldn't use this function:
    Quote Originally Posted by MSDN
    [Internet Connection Firewall may be altered or unavailable in subsequent versions. Instead, use the Windows Firewall API.]
    Anyway, you can try to dynamically link the function at runtime:
    Code:
    #include <windows.h>
    #include <tchar.h>
    #include <NetCon.h>
    
    typedef void (WINAPI *PFNNcFreeNetconProperties)(NETCON_PROPERTIES* pProps);
    
    int main(int argc, char* argv[])
    {
        // function pointer
        PFNNcFreeNetconProperties NcFreeNetconProperties;
    
        // load DLL
        HMODULE hDLL = LoadLibrary(_T("netshell.dll")); // or hnetcfg.dll
        if (!hDLL)
        {
            // dll not found
            return 0;
        }
    
        // get procedure address
        NcFreeNetconProperties = (PFNNcFreeNetconProperties)GetProcAddress(hDLL, "NcFreeNetconProperties");
        if (!NcFreeNetconProperties)
        {
            // procedure not found
            return 0;
        }
    
        // call procedure
        NcFreeNetconProperties( ... );
    
        // Free dll when done
        FreeLibrary(hDLL);
    
        return 0;
    }
    - petter

  3. #3
    Join Date
    Dec 2006
    Location
    Minneapolis, Minnesota
    Posts
    33

    Re: Linking question on NcFreeNetconProperties(NETCON_PROPERTIES*);

    This works. Thanks much. BTW, this is an MFC app. Is is more appropriate to use AfxLoadLibrary?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured