Subj : Re: Creating DLLs with Borland C++ 5.5 For Use In VB (Not COM or OLE) To : borland.public.cpp.borlandcpp From : "Dennis Jones" Date : Fri Oct 03 2003 01:00 pm "David Cravey" wrote in message news:3f7cd162@newsgroups.borland.com... > Hi, > > I am wanting to create a few very simple DLLs to export a few functions (not > classes) that I can use in Visual Basic. My company requires me to use > Visual Basic, but sometimes I need to create a few processing routines that > are not impossible but very slow in VB. If anyone has an example C file > which exports one or more functions which can be used by VB then I would be > very appreciative. As Ed has already said, this is indeed the wrong newsgroup for questions abot the free Borland compiler, however the information you need should be the same for all Borland compilers, so I will provide it here. There is a great article in the August 1996 issue of the Windows Developer's Journal which addresses the issue of creating generic DLL's that can be used by any Windows application. Essentially, it boils down to making sure the calls are decorated properly and have the right calling sequence. In your DLL header file: /* Begin MyDll.h */ #if !defined( _MYDLL_LIB_ ) #define MYDLL_API extern __declspec( dllimport ) // make functions importable #else #define MYDLL_API extern __declspec( dllexport ) // make functions exportable #endif #define CALLSEQ __stdcall #ifdef __cplusplus extern "C" { #endif MYDLL_API void CALLSEQ SomeDLLFunc( void ); #ifdef __cplusplus } #endif /* End MyDll.h */ In your DLL source file: /* Begin MyDll.c[pp] */ #define _MYDLL_LIB_ // makes the functions exportable #include "MyDll.h" #ifdef __cplusplus extern "C" { #endif MYDLL_API void CALLSEQ SomeDLLFunc( void ) { // do something } #ifdef __cplusplus } #endif /* End MyDll.c[pp] */ Then, to use the functions in the DLL, just include the header: #include "MyDll.h" int main( void ) { SomeDLLFunc(); return 0; } Hope this helps, - Dennis .