I am trying to write a wrapper functions around C.dll ( pbmman32.dll, if someone is familiar with it ) to use with c#.
Looking at the header files of the source, it doesn't seem that they implement __declspec(dllexport) although they do use extern "C"{}. Can i still call functions within that dll with the dllexport line missing?
For example:
BOOL PBM_Version (TCHAR* Buffer, WORD* Version, DWORD Size)
into:
[DllImport("pbmman32.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
public static extern bool PBM_Version(StringBuilder Buffer, StringBuilder Version, System.UInt32 Size);
The vendor might have supplied a header file for you to use when importing rather than the version they used to build the DLL. More likely is that they exported the functions with a .def file. But there's no compulsion to use
__declspec(dllexport). Stop worrying about its absence.I am sceptical of your translation though. The second parameter is probably an unsigned 2 byte type, passed as an out param. Declare it like this:
Decode the major version number with
version >> 8and the minor withversion & 0xff.It's not enough to read the header file alone. You must read the documentation too.
The other area which gives cause for concern is the use of
TCHAR. Does the library really offer ANSI and Unicode exports?