Importing DLL / Library Files

This is a discussion on Importing DLL / Library Files within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to use a class which is located in the file Iphlpapi.h. I know this file lives in ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    35

    Question Importing DLL / Library Files

    I am trying to use a class which is located in the file Iphlpapi.h.
    I know this file lives in iphlpapi.dll.

    How do I import this class/library/dll?

    I know the dll lives at c:\windows\system32

    I have tried #import "c:\windows\system32\iphlpapi.dll", but this did not work.

    How to I import and use this class?

    O/S: Windows XP Pro
    Compiler: MS VC++ 6.0

    Many Thanks

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Statically link iphlpapi.lib into your application (the same way you'd link most windows libs) - your compiler will have specific details on how to do this but there should be someplace to do this in 'project settings' (or properties?) if my bad memory serves me correctly. Or you can achieve the same thing with something like #pragma comment(lib,"iphlpapi").

    For run-time, dynamic linking use LoadLibrary but you'll need to use GetProcAddress if you want to use any of the dll's functions of the loaded library.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    Here's how to manually link:
    Using .dll files

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    35
    When I try #pragma comment(lib,"iphlpapi") I get the following error

    LINK : fatal error LNK1104: cannot open file "iphlpapi.lib"

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    35
    Ok, so now I switched compilers to Borland CBuilder 5.0
    The iphlpapi.h resides in the include folder, I can #include to file.

    When I compile I get this error...

    Unresolved External 'GetApatersInfo'

    Although the Borland shows me the function prototype when I am coding.

    I really need help on this one. I can't link the dll in MS VC++ nor can I call the function from Borland CB

    Anyone please!

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    Did you include the lib in the projects settings?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 06:16 AM
  2. OpenCV Library - problems with dll files
    By nipun in forum Windows Programming
    Replies: 3
    Last Post: 11-21-2004, 09:36 AM
  3. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM
  4. DLL files
    By neandrake in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2002, 03:31 PM
  5. importing program files
    By altoba in forum C Programming
    Replies: 1
    Last Post: 01-21-2002, 11:43 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21