Subj : Re: Creating DLLs with Borland C++ 5.5 For Use In VB (Not COM or OLE) To : borland.public.cpp.borlandcpp From : "David Cravey" Date : Sat Oct 04 2003 02:13 pm Dennis, Thank you sooo much for your help. I have not figured it all out yet, but I am heading in the right direction. I am still getting a VB error 48 "Cannot find dll", and when I downloaded the code you mentioned in windows developers journal I had the same results. I am guessing I am not using some command line option that I need. I will also try the code on my Borland C++ 5 compiler. (I am not using it right now because I have a hard time making it compile both windows programs and 186 Dos programs, we have an embedded 186 I have to develope for.) Thanks again!!! Thanks, David ----- Original Message ----- From: "Dennis Jones" Newsgroups: borland.public.cpp.borlandcpp Sent: Friday, October 03, 2003 2:00 PM Subject: Re: Creating DLLs with Borland C++ 5.5 For Use In VB (Not COM or OLE) > > "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 > > .