Making a DLL in C/C++ that I can use in VB
black eyez  


My friend has developped a directx wrapper-type lib for c++ (using classes). We would like to be able to somehow make a dll out of it so that it can be used from VB. Is this possible? How difficult would this be? 

David Goodlad


You'll have to have your functions exportable, 
For a DLL, you don't have a WinMain(), you have a DLLMain() 
It looks something like this 

BOOL WINAPI DllMain(HINSTANCE hInstA, DWORD dwReason, LPVOID lpvReserved) 

Your dll export should look similar to this: 
__declspec(dllexport) WINAPI MyFuncitonName() 

In your header file, you'll have 
__declspec(dllexport) WINAPI MyFunctionName(); 

And in your .def file, you'll setup the list of exported functions like this: 

MyFucntionName @1 
MyOtherFunctionName @2 
AndAnotherOne @3 

I hope that helps to point you in the right direction. 
Happy Programming, 


black eyez  

Okay thanks... But, as I'm not the most experienced c++ programmer (I didn't personally write the wrapper), I'm still curious as to how I would use classes as defined in the c++ files. Is there any way to do this?


In what way do you want to use classes? In a DLL, I don't think its possible. To my knowledge a DLL only conatain functions that can be access via other programs. If there are any classes inside a dll, I think they have to be encapsulated, otherwise it won't work. 

If that's not what you had in mind, you could always create an OCX, that might be usefull to you. 

I'm not very familiar with c++ either, so what i've said could very well be wrong.