0

I'm programming with Borland C++Builder 6 for my school project. Its a very old builder, but its not my choice.

I managed everything but I have to get the MAC address of the user's computer. There are many working sample for C++, but they are not working on Borland C++ Builder 6. It says iphlpapi.lib is missing.

Can anybody who knows Borland help me to overcome this subject?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Rose_The_Only
  • 238
  • 9
  • 21
  • 1
    Since you are using a very old compiler, it should be enough to link against ws2_32.lib/.dll (that is the 32bit version of windows socket api). – user6556709 Mar 06 '19 at 09:08
  • @user6556709 What's the function in ws2_32.lib that returns a MAC address? – Rup Mar 06 '19 at 11:40
  • Check this https://stackoverflow.com/questions/13646621/how-to-get-mac-address-in-windows-with-c Except the VC++ #pragma comment(lib, "iphlpapi.lib") for linking library rest is the same . How to link a [win api dll](http://www.yevol.com/bcb/Lesson06.htm) – Victor Gubin Mar 06 '19 at 11:40
  • It's a bit more work, but if you can't find iphlpapi and the version in a recent Window SDK isn't compatible with Borland C++ (I'd guess not?), you can always use LoadLibrary and GetProcAddress to load iphlpapi.dll and resolve the function to call at runtime. – Rup Mar 06 '19 at 11:41
  • @VictorGubin But OP doesn't have a copy of iphlpapi.lib to link to. – Rup Mar 06 '19 at 11:42
  • 1
    @Rup as far as I remember Delphi and Builder have an additional exe to convert MS VC++ import librarian to Borland format, as well as a tool to extract import library from the existing dll. – Victor Gubin Mar 06 '19 at 11:45
  • @VictorGubin Neat! Then that's the answer I think: generate it from the DLL with this tool, if you can remember what it's called / how to use it? – Rup Mar 06 '19 at 11:47
  • 1
    I think this should be [implib](http://www.yevol.com/bcb/Lesson06.htm) i.e. something like `implib iphlpapi.lib c:\Windows\System32\IPHLPAPI.DLL` – Victor Gubin Mar 06 '19 at 11:48
  • 1
    The Borland version of `implib` is probably `tlibimp`. I am not sure that was the name of the BCB6 version too (after all, BCB6 was released 2001), but I guess so. – Rudy Velthuis Mar 06 '19 at 11:59
  • 3
    I use Borland C++Builder 6 myself for work, and I can say with absolute certainty that it DOES have its own `iphlpapi.lib` file, located in the `$(BCB)\Lib\Psdk` folder. You DO NOT need to use `implib` (and yes, it is named `implib` in BCB6) on `iphlpapi.dll`. And `#pragma comment(lib, "iphlpapi.lib")` works fine in BCB6, you just have to make sure your project's Lib search path is configured correctly. I have used the `GetAdaptersInfo()` and `GetAdaptersAddresses()` functions in my BCB6 projects and they work just fine. – Remy Lebeau Mar 06 '19 at 19:02

0 Answers0