
Howto: declare a C function that registers a callback in IDL
Quote:
> Add extern "c" to your function declaration
Thanks, but that doesn't solve the problem, the functions are exported
through a .def file, sorry I should have included the .def file in the
original post, I have included it below (note that usage of the ";"
comment has been correctly added/removed depending on my test). In my
recent tests, I definitely seem to have a registry problem, although I
can't pin it down, there is *very* little support for unregistering a
.tlb file from microsoft. I rolled my own, using the ITypeLib APIs,
which seems to work on the surface but I'm still getting the error even
when I remove fnCTestCB from both the C DLL and the .idl.
<rant>
COM is great for what it does but, it's dependency on the registry makes
it extremely volatile, MS should really give more support. This whole
thing came about because of the difference in struct alignment in VB and
C/C++, VB has to 4-byte while C/C++ defaults to 8-byte, this requires VB
applications to hack into it's type defintions with padding Byte arrays
or use a TypeLib. The TypeLib solutions seems the right way to go, but
it is turning into a small nightmare to wrap the whole thing and not
just the type defintions. I am surprised that MS has not given more
information on how to wrap a C DLL in a TypeLib, since that seems to be
the most reliable way to interface to C DLLs.
About this VB problem:
1) View dependencies doesn't see fnCTestCB
2) OLE/COM Viewer doesn't see fnCTestCB
3) VB returns ""Can't find dll entry point fnCTestCB in CTest.dll" even
when the function does not exist.
</rant>
Thanks
CTest.def -------
; DEF file
EXPORTS
fnCTest
;fnCTestCB