There have been projects I have been on in the past where there was certain functionality I needed but could not get from VB, or I had to do a complete workaround to get the functionality I could get from C++ very easily. In this tutorial I will show you how to create a C++ dll that you can call from VB. I figure instead of doing the norm, "HELLO WORLD", or "ADD NUMBER", routine I will show you how to resolve a domain name to an IP address and return that IP address back to VB, this is a little advanced for the beginner but if you have some C++ experience it wont be that bad.
For this example I will be using VC++ 6 so if you have that IDE then you will be right at home and in the case you do not use that IDE then just try to follow along and enjoy the ride!
Ok, you will first have to create a new dynamic link library project. After you create this project you will be prompted on what kind of DLL, just click empty.
After that is complete you will have to add the library ws2_32.lib to the project under project-> settings -> link -> object/modules library or the code below will not compile! Believe me when I tell you this as I had the fun of learning this the hard way and it was a nightmare.
Comments