Home>

I started touching C # the other day.

and I am trying to call a DLL from C #.
There is a function pointer for callback in the argument.

I don't know the case of specifying a callback for this pointer, but
Normally it seems to set -1.
However, I don't know how to set the function pointer to -1.

Specifically,
This is the fifth argument of the sqlite3_bind_text function of winsqlite3.dll.

Applicable source code
typedef void (SQLITE_CALLBACK * sqlite3_destructor_type) (void *);
#define SQLITE_STATIC ((sqlite3_destructor_type) 0)
#define SQLITE_TRANSIENT ((sqlite3_destructor_type) -1)
SQLITE_API int SQLITE_APICALL sqlite3_bind_text (sqlite3_stmt *, int, const char *, int, void (SQLITE_CALLBACK *) (void *));
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
public delegate int sqlite3_destructor_type (IntPtr param);
[DllImport ("winsqlite3.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int sqlite3_bind_text (IntPtr Stmt, int iCol, string Value, int Length, sqlite3_destructor_type cb);
const sqlite3_destructor_type SQLITE_TRANSIENT = (sqlite3_destructor_type) (-1);
int status = sqlite3_bind_text (Stmt, i, args [i] .ToString (), -1, SQLITE_TRANSIENT);
Tried

I don't think I'll be able to escape if I don't write a callback declaration on the declaration side, but make it IntPtr ...

[DllImport ("winsqlite3.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int sqlite3_bind_text (IntPtr Stmt, int iCol, string Value, int Length, IntPtr cb);
static IntPtr SQLITE_TRANSIENT = (IntPtr) (-1);