7.4 DLL CC argument construction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

7.4 DLL CC argument construction

Adams, Charles

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


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: 7.4 DLL CC argument construction

Wallen, David

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

 

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Adams, Charles
Sent: Friday, June 25, 2010 9:09 AM
To: [hidden email]
Subject: [vwnc] 7.4 DLL CC argument construction

 

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


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc