Re: New to DLLs

From: J French (erewhon_at_nowhere.com)
Date: 09/15/04


Date: Wed, 15 Sep 2004 08:08:34 +0000 (UTC)

On 14 Sep 2004 21:03:52 -0700, jloriena@hotpop.com (Jessica Loriena)
wrote:

>Great explanation! I'm finally getting to know a little more about
>DLLs.. Thanks a million!

Rob's advice was spot on

How I generally do it is to have an Array of Objects in the main Unit
of the DLL

The: SomeDllCreate checks for an unused member of the Array, then
creates that Object and returns the number of the Object in the Array
as the 'Handle'

>From then on the EXE passes the 'Handle' to the DLL as the first
parameter, in the DLL

Procedure DoSomething( Const Handle :Integer );StdCall;
Begin
    ObjArray[ Handle ].DoSomething;
End;

Another thing, passing back Strings from a DLL is not a good idea,
however they can be passed back very nicely as strings in OleVariants

This is because OleVariants use a different (shared) system for memory
allocation, and when returned as the Result of a Function, they are
really an extra hidden parameter sent in from the caller.



Relevant Pages

  • passing an array of LPSTR to C++ by reference
    ... I have written a VB program that passes an array of strings to a C++ ... The c++ dll is supposed to fill the array of strings with the ... GetJobIds(LPSTR & strReturnedJobId, int ...
    (comp.lang.cpp)
  • Re: Is a Thread appropriate?
    ... >> Now, if you are not doing dynamic loading of the DLL, you shouldn't need GetProcAddress. ... >> Note that it is foolish to create a char array, particularly a char array of a fixed size. ... >> If you need to declare a separate variable, ... without necessity. ...
    (microsoft.public.vc.mfc)
  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)
  • VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)
  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.basic.visual.misc)