Questions on my first DLL program 
Author Message
 Questions on my first DLL program

Thanks to those of you who have helped me so far in writing my first DLL
for ParadoxWin(4.5), but there is still some conceptual stuff that I'm not

clear on.  (Perhaps this should be in comp.lang.c, but this group has been
much more helpful and might better understand my C/Paradox plight)).
    I think I've got the DLL call in Paradox set up correctly, but the C
program
side is still getting me.  Actually I'm converting a C for DOS (Borland)
program
I wrote a few years back to C for Windows(Borland) so I can create a DLL.

1)    Since the DLL is not executable, is it OK to write it an an exe,
then
    convert the results to a DLL?  If not, how do you test the program as
you
    are writing it?

2)    Can I safely assume that variables used in the DLL call will return
updated?
     If not, how do I update these variables?

3)    Is there any problem passing arrays to or from DLLs?

These seem like silly questions, but I'm having a hard time figuring what
to do
when.

    A kindly tip of the hat for any assistance,   ...ADAM

Adam Jones
Indianapolis, Indiana



Tue, 30 Jun 1998 03:00:00 GMT
 Questions on my first DLL program

Quote:

>Thanks to those of you who have helped me so far in writing my first DLL
>for ParadoxWin(4.5), but there is still some conceptual stuff that I'm not
>clear on.  (Perhaps this should be in comp.lang.c, but this group has been
>much more helpful and might better understand my C/Paradox plight)).
>    I think I've got the DLL call in Paradox set up correctly, but the C
>program
>side is still getting me.  Actually I'm converting a C for DOS (Borland)
>program
>I wrote a few years back to C for Windows(Borland) so I can create a DLL.
>1)    Since the DLL is not executable, is it OK to write it an an exe,
>then
>    convert the results to a DLL?  If not, how do you test the program as
>you
>    are writing it?

Sounds like a reasonable strategy.  Once you've tested the routines, using a
dummy main-program, spin it off into a DLL and write a short test program that
calls the DLL.  Be sure it works the same as before.

Quote:
>2)    Can I safely assume that variables used in the DLL call will return
>updated?
>     If not, how do I update these variables?

It all depends upon how you are passing the values -- by reference or by
value.  The normal procedure is to allocate a record-type, pass that (by
reference) to the DLL routine, and write the DLL to return the values into
that record, which Paradox has allocated for you and will manage.

Quote:
>3)    Is there any problem passing arrays to or from DLLs?

Arrays are definitely problematic; not so much in principle, but because in
practice it is very easy to scribble on memory.  When you clobber Paradox he
tends to, well, "ick."  So perhaps your DLL routine could cache the values
that he needs in his own storage, and provide means for Paradox to fetch the
values back one at a time, with your DLL doing the necessary range-checks to
be sure a fire does not break out.

/mr/



Tue, 30 Jun 1998 03:00:00 GMT
 Questions on my first DLL program

Quote:

> Thanks to those of you who have helped me so far in writing my first DLL
> for ParadoxWin(4.5), but there is still some conceptual stuff that I'm not

> clear on.  (Perhaps this should be in comp.lang.c, but this group has been
> much more helpful and might better understand my C/Paradox plight)).
>     I think I've got the DLL call in Paradox set up correctly, but the C
> program
> side is still getting me.  Actually I'm converting a C for DOS (Borland)
> program
> I wrote a few years back to C for Windows(Borland) so I can create a DLL.

> 3)    Is there any problem passing arrays to or from DLLs?

DO NOT try to pass arrays, or any other complex data type,
directly to a C routine.  The only data types compatible with C
are String, Longint, Smallint, and Number.  Logicals are sorta
compatible, but must be converted to smallints for use with a
dll, and then back again after the dll call, since they really
are just integers.

OK, so the problem with arrays is that they aren't really
arrays.  Like an array of Smallints, say, in C is just a list of
16 bit values in memory, but in Paradox, they are a list of 32
bit values that point to smallint objects.  It takes some amount
of code to convert, and it takes C code to do it.  If you really
must send arrays or records to C, I have some C code that will
allow you to do it, so EMail me with some specifics and I'll see
what I can do...

Good Luck

Glen Parker



Thu, 02 Jul 1998 03:00:00 GMT
 Questions on my first DLL program
    Thanks to all for your help on this DLL project, it's working
like a charm now.  
    Seems like the more difficult he project, the more satisfying
the result.

        ...ADAM

Adam Jones
Indianapolis, Indiana



Sun, 05 Jul 1998 03:00:00 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. A question about First Choice database program

2. Can we turn Foxpro programs into DLL which can be called by other non-Foxpro programs

3. First-chance exception in Client.exe (KERNEL32.DLL): 0xC0000005:

4. My first database program

5. Help! Stuck on first ADO Program

6. First time DB program, need help

7. First DCOM small network program Access DB

8. ESQL/C Program - Get First, Get Next Record in Table

9. Programming Informix SQL/$GL, Cathy Kipp, first edition examples code

10. Compiling first ADO program...a few errors

11. PRG HELP - First-time FoxPro program


 
Powered by phpBB® Forum Software