More FFI Help with long buffers
Ron Teitelbaum
Ron at USMedRec.com
Tue Aug 8 00:20:56 UTC 2006
Hello all,
I've been having some trouble with an api call. I need to send in a long
value as a buffer.
I've tried a few things.
1: just using an external address allocated to 4 bytes using an integer
address.
MyExtFunc >> withBuffer: aBuffer
<apicall: bool 'MyAPICall' (long) module: 'my.dll'>
------------------
MyExtFunc >> callWithBuffer
aBuffer := ExternalAddress allocate: 4.
self withBuffer: aBuffer getHandle asInteger.
-------------------
2: Using a pointer to ExternalAddress
MyExtFunc >> withBuffer: aBuffer
<apicall: bool 'MyAPICall' (ExternalAddress*) module: 'my.dll'>
--------------------
MyExtFunc >> callWithBuffer
aBuffer := ExternalAddress allocate: 4.
self withBuffer: aBuffer
-------------------
3: Creating external structure that holds a long
MyExtFunc >> withBuffer: aBuffer
<apicall: bool 'MyAPICall' (Win32LongBuffer*) module: 'my.dll'>
-------------------
MyExtFunc >> callWithBuffer
aBuffer := Win32LongBuffer new buffer: 0; yourself
aBuffer setHandle: (ExternalAddress allocate: 4).
self withBuffer: aBuffer
-------------------
4: I tried the Win32LongBuffer as (long) with aBuffer getHandle asInteger
-------------------
5: I tried ExternalData using Cees method:
argBuf _ ByteArray new: 4.
argBuf longAt: 1 put: 0 bigEndian: false.
argPtr _ ExternalData fromHandle: argBuf type: ExternalType long
asPointerType.
-------------------
6: extData := ExternalData fromHandle: (ptr := ExternalAddress allocate: 4)
type: ExternalType long [asPointerType]
Sending in the handle of the extData or the ptr and I tried both as integer.
So far nothing is working. I believe that the problem is the buffer. Does
anyone have any suggestions of other things I could try?
The Error I'm receiving is consistent:
//
// MessageId: ERROR_ALREADY_EXISTS
//
// MessageText:
//
// Cannot create a file when that file already exists.
//
#define ERROR_ALREADY_EXISTS 183L
I'm not sure what that means. Googleing it didn't help much.
Does anyone have some suggestions on how to send in a long buffer for the
api to fill?
Any help would be greatly appreciated!
Thanks,
Ron Teitelbaum
More information about the Squeak-dev
mailing list
|