Re: Win32 API Declarations

new topic     » goto parent     » topic index » view thread      » older message » newer message

David Cuny writes:
> I had based my API declarations on the Visual Basic API file.
> These declarations turn out not to be as complete as they need
> to be. For example, I had declared an API call as C_LONG when
> it should have been C_UINT; this caused it to fail under WinNT.
> Win95 seems fairly lax about handling parameters. For example,
> I've declared CheckMenuItem as {C_LONG, C_LONG, C_LONG},
>  whereas the WIN.H prototype suggests {C_POINTER,C_UINT,C_UINT}.

In Euphoria, when you declare the type of parameters to C routines, all
the 4-byte types, int or pointer, are equivalent. It doesn't matter which
one you use, other than maybe documentation value for someone
reading your code. A 4-byte quantity will be pushed on the stack,
and the C subroutine will interpret it however it likes. One or
two-byte types (char and short) are also passed as 4 bytes.
C doubles are passed as 8 bytes.

The *return* type of a C routine that you call from Euphoria
must be correctly declared regarding "signed" or "unsigned",
or you may get the wrong value returned for negative numbers
or very large positive (i.e. high-order bit is 1).

> So now I need to go back through my declarations and make sure they
> are set up correctly. I'm not sure how to map all the arguments,
> though. Specifically, BOOL and handles. I would guess a handle
> maps to a C_POINTER; I'm less sure about BOOL.

In WIN32, I think a handle is equivalent to an unsigned long.
A BOOL is probably an unsigned int, but I'm not sure.
(long and int are equivalent in the 32-bit world.) In any case, both
are probably "unsigned 4-byte types", which is all that matters.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu