1. DLL trouble

This time i'm losing my mind trying to compile my DLL that i'm writing in C
so that i can use the functions in it in Euphoria

Any help would be greatly appreciated

Ian.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

new topic     » topic index » view message » categorize

2. Re: DLL trouble

>From: No Solution <solutionnone at HOTMAIL.COM>
>Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU>
>To: EUPHORIA at LISTSERV.MUOHIO.EDU
>Subject: DLL trouble
>Date: Sun, 22 Oct 2000 20:03:11 PDT
>
>This time i'm losing my mind trying to compile my DLL that i'm writing in C
>so that i can use the functions in it in Euphoria
>
>Any help would be greatly appreciated
>
>Ian.

never mind everbody! i fixed my problem!

if you want to see how i fixed my problem email me and i'll show you!

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

new topic     » goto parent     » topic index » view message » categorize

3. Re: DLL trouble

No Solution wrote:

> This time i'm losing my mind trying to compile my
> DLL that i'm writing in C so that i can use the
> functions in it in Euphoria

Just thought I'd mention - I've posted a version of SWIG that is capable of
generating wrappers for some C libraries automatically, making it less
painful to interface Euphoria to DLLs.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

4. Re: DLL trouble

>This time i'm losing my mind trying to compile my
>DLL that i'm writing in C so that i can use the
>functions in it in Euphoria
>


You'll need this:

BOOL WINAPI LibMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
  case DLL_PROCESS_ATTACH:
   return TRUE;
   break;
  case DLL_PROCESS_DETACH:
   break;
  case DLL_THREAD_ATTACH:
   break;
  case DLL_THREAD_DETACH:
   break;
}
return TRUE;
}


plus, you usually need to supply a definition-file (*.def). This file should
look like this:

EXPORTS
func_1
func_2
...
func_n

(where func_1..n are the functions you wish to make linkable).
You include this file on the commandline when you link your program.

You may also have to declare those functions as _dllexport (or something
like that). it's not needed with msvc though.

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

new topic     » goto parent     » topic index » view message » categorize

5. DLL trouble

I'm accessing DLL's with the open_dll function, e.g.}}}
<eucode>
include dll.e
constant kernel32 = open_dll("kernel32.dll"),
 cSetEndOfFile = define_c_func(kernel32, "SetEndOfFile", {C_UINT},  C_UINT)
</eucode>
{{{

but what do I do if I need to use a function that takes parameters other than
the ones built-in, namely: }}}
<eucode>
global constant 
	 C_CHAR    = #01000001,
	 C_UCHAR   = #02000001,
	 C_SHORT   = #01000002,
	 C_USHORT  = #02000002,
	 C_INT     = #01000004,
	 C_UINT    = #02000004,
	 C_LONG    = C_INT,
	 C_ULONG   = C_UINT,
	 C_POINTER = C_ULONG,
	 C_FLOAT   = #03000004,
	 C_DOUBLE  = #03000008
</eucode>
{{{

Many functions take more advanced "struct" arguments.  What do I use in that
case?

If there's no way around this limitation, does anyone know a better way "into"
DLL's than the open_dll function?  I'm also a little frustrated in that I can't
access global constants defined in the DLL.

Thanks in advance for any help!

new topic     » goto parent     » topic index » view message » categorize

6. Re: DLL trouble

K. Einfeldt wrote:
> 
> I'm accessing DLL's with the open_dll function, e.g.}}}
<eucode>
> include dll.e
> constant kernel32 = open_dll("kernel32.dll"),
>  cSetEndOfFile = define_c_func(kernel32, "SetEndOfFile", {C_UINT},  C_UINT)
> </eucode>
{{{

> but what do I do if I need to use a function that takes parameters other than
> the ones built-in, namely: }}}
<eucode>
> global constant 
> 	 C_CHAR    = #01000001,
> 	 C_UCHAR   = #02000001,
> 	 C_SHORT   = #01000002,
> 	 C_USHORT  = #02000002,
> 	 C_INT     = #01000004,
> 	 C_UINT    = #02000004,
> 	 C_LONG    = C_INT,
> 	 C_ULONG   = C_UINT,
> 	 C_POINTER = C_ULONG,
> 	 C_FLOAT   = #03000004,
> 	 C_DOUBLE  = #03000008
> </eucode>
{{{

> Many functions take more advanced "struct" arguments.  What do I use in that
> case?
> 
> If there's no way around this limitation, does anyone know a better way "into"
> DLL's than the open_dll function?  I'm also a little frustrated in that I
> can't
> access global constants defined in the DLL.
> 
> Thanks in advance for any help!

You have to allocate memory for any structure size that you wish to

use.

Then you have to poke the values into the appropriate location

in your memory structure.


Then when you call your function you pass the memory address of

that structure.

You can look at any of the window libraries in the archive to see

how they create their structures.

It would probably be easier for you to use the one of window libraries that

are already created.


Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

7. Re: DLL trouble

K. Einfeldt wrote:
> 
> I'm accessing DLL's with the open_dll function ...

> but what do I do if I need to use a function that 
> takes parameters other than the ones built-in ...

> Many functions take more advanced "struct" arguments...


There are very, very few DLL calls that need a struct. Usually they take a
pointer to a struct, which Euphoria can handle with a C_POINTER.

Can you give an example so we can work out an alternative?

> I'm also a little frustrated in that I can't
> access global constants defined in the DLL.

Does the define_c_var routine not work for you?


-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view message » categorize

8. Re: DLL trouble

K. Einfeldt wrote:
> 
> I'm accessing DLL's with the open_dll function, e.g.}}}
<eucode>
> include dll.e
> constant kernel32 = open_dll("kernel32.dll"),
>  cSetEndOfFile = define_c_func(kernel32, "SetEndOfFile", {C_UINT},  C_UINT)
> </eucode>
{{{

> but what do I do if I need to use a function that takes parameters other than
> the ones built-in, namely: }}}
<eucode>
> global constant 
> 	 C_CHAR    = #01000001,
> 	 C_UCHAR   = #02000001,
> 	 C_SHORT   = #01000002,
> 	 C_USHORT  = #02000002,
> 	 C_INT     = #01000004,
> 	 C_UINT    = #02000004,
> 	 C_LONG    = C_INT,
> 	 C_ULONG   = C_UINT,
> 	 C_POINTER = C_ULONG,
> 	 C_FLOAT   = #03000004,
> 	 C_DOUBLE  = #03000008
> </eucode>
{{{

> Many functions take more advanced "struct" arguments.  What do I use in that
> case?
> 

Structures are passed as pointers, so use C_POINTER for any such argument. 

You may have problems if the structure is passed by value, as might be the case
for 64/128-bit integers (see a recent post). AFAIK, this is a very rare case, at
least in the Windows API. Perhaps using C_DOUBLE for 64-bit integers might work,
don't know for SSE2-defined 128-bit integers.

> If there's no way around this limitation, does anyone know a better way "into"
> DLL's than the open_dll function?  I'm also a little frustrated in that I
> can't
> access global constants defined in the DLL.
> 

Use }}}
<eucode>define_c_var(entry_point,var_name)</eucode>
{{{
. That will give you an
address to peek/poke at.

HTH
CChris

> Thanks in advance for any help!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu