Reading the 'man' page for curl_formadd(), it says there:
The pointers firstitem and lastitem should both be pointing to NULL in the first call to this function.
You, however, pass NULL for these.
You also seem to be passing the strings incorrectly. Try defining the Value1 and Value2 parameters "as CString", then pass normal Strings, not Memoryblocks.
Lastly, you gave CURLFORM_COPYCONTENTS the wrong code. It's not 2 but 4. See the CURLformoption enum in curl.h: "CFINIT(NOTHING)" gets value 0, and every item past that gets one higher, so CFINIT(COPYCONTENTS) gets 4.
Here's the code that works for me:
Declare Function curl_global_init Lib "libcurl" (flags As Integer) As Integer
Declare Function curl_formadd Lib "libcurl" (ByRef FirstItem As Ptr, ByRef LastItem As Ptr, Option1 As Integer, Value1 As CString, Option2 As Integer, Value2 As CString, EndMarker As Integer) As Integer
Const CURLFORM_COPYCONTENTS = 4
Const CURLFORM_COPYNAME = 1
Const CURLFORM_END = 17
const CURL_GLOBAL_ALL = 3
Dim formname, formvalue As String
formname = "NAME"
formvalue = "CONTENTS"
If curl_global_init(CURL_GLOBAL_ALL) = 0 Then
Dim first, last As Ptr
Dim err As Integer
err = curl_formadd(first, last, CURLFORM_COPYNAME, formname, CURLFORM_COPYCONTENTS, formvalue, CURLFORM_END)
Break
' err is 0
End If