If you want to uses some C++ code from VB.NET, the best solution is to uses C++/CLI and uses managed code to interface between VB.NET and C++.
class RegularCppClass
{
};
public ref class CppCliClassForVb
{
public:
property System::String ^Test;
int GetCpuSpeed();
private:
RegularCppClass *regularCppClass;
};
Destructors and finalizers in Visual C++[
^]
That class can uses regular C++ object if it need to. C++ object need to be allocated by pointer or reference.
If you need in some case to go the other way (a C++ class need to have an hadle to a managed object, you will need gcroot< > (
http://msdn.microsoft.com/en-us/library/481fa11f(v=VS.100).aspx[
^]).
By using a managed layer between your C++ code and VB, it will be much simpler to uses from VB. You will just have to add a reference to the DLL.
By the way, your C++ code will need to be compiled as managed but with support for standard C++ (assuming you want to uses regular C++ code). That is, you need the option /clr (
http://msdn.microsoft.com/en-us/library/k8d11d4s.aspx[
^]). This option is available in your project settings.