Click to See Complete Forum and Search --> : Help in wrapper dll


chook
November 6th, 2008, 10:44 PM
Hi guys,

I'm developing an app in VB with a provided DLL from 3rd party. The SDK they provided includes a .dll file, .h file and .lib file, however this dll was written in CDECL calling convention which is unable to use in VB. So I started to do the wrapping DLL in STDCALL in C++ that calling functions from existing DLL, but my knowledge in C++ is very limited and I have no idea where should I start it with.

Any guidance would be highly appreciate.

Cheers

TheCPUWizard
November 6th, 2008, 11:46 PM
Well, the wrapper can be straight "C"...no need for objects.

You just create one function for every function in the DLL (at least those you are going to use). Give it the same parameters and return types, and just add a prefix/suffix to the function name.....

There really is no "programming" involved...just a bunch of typing....

chook
November 7th, 2008, 12:07 AM
Thanks for your reply, just wanna make sure I'm not off track, this is what i've been doing:

- First, i created a empty dll project in VS C++, included the existing .h file and linked .lib file. This is code of the existing .h file:

#define IVCSDK68_API extern "C" __declspec(dllimport) '<=== original was dllexport, I changed it to dllimport

IVCSDK68_API int IVCSDK68_InitSDK();


- Next, I made a .h file for my tempting DLL (I called it DLL4VB.h), and declarations are:

int __stdcall VB_InitSDK();


- Next, I created a .cpp file

#include "IEIDLL4VB.h"
#include "IVCSDK68.h"

int __stdcall VB_InitSDK()
{
return IVCSDK68_InitSDK;
}


So is that the right way of doing it?

Thanks heaps to TheCPUWizard