This snippet might work. There is a more
detailed example below that.
strings := OrderedCollection new add:
'one'; add: 'two'; add: 'three'; add: 'four'; add: 'five'; yourself.
pArray := CIntegerType char pointerType
malloc: 5.
0 to: 4 do: [:i|
pStr
:= (strings at: (i+1)) copyToHeap.
pArray
at: i put: pStr].
DDC_AppendDataValuesString (channel,
pArray, 5);
0 to: 4 do: [:i|
pStr
:= pArray at: i.
pStr
free].
pArray free
===================================================
pArray := CIntegerType char pointerType
malloc: 4.
0 to: 3 do: [:i|
pStr
:= ('Number ', i printString) copyToHeap.
pArray
at: i put: pStr].
pArray inspect.
0 to: 3 do: [:i|
Transcript
show: (pArray at: i) copyCStringFromHeap; cr].
0 to: 3 do: [:i|
pStr
:= pArray at: i.
pStr
free].
pArray free
I
have this DLL interface that looks like this:
DDC_AppendDataValuesString:
channel with: values with: numValues
<C: int __stdcall DDC_AppendDataValuesString(DDCChannelHandle channel,
const char * values[], size_t numValues)>
I
don’t understand how to construct the values[] argument.
>From the DLL’s documentation:
“When
calling DDC_AppendDataValuesString, you must pass
an array of type character pointer (char *). The following code
illustrates one way to pass an array of strings:
char *values[] = {"one", "two",
"three", "four", "five"};
DDC_AppendDataValuesString (channel, values, 5);”
Charles Adams