On Sun, 20 Jun 2004 14:55:21 +0200, "SamoK" <sn***@wetsoftware.com>
wrote:
Hy!
I have to invoke a function that has a FILE pointer for its parameter.
e.g.
int myfunct(FILE *f);
Does anyone know how can P/Invoke such function? And would it be possible to
pass StreamReader as a parameter to an invoked function (I know it is not
possible to do so directly)?
Thanks in advance
- Samo
Well, treat the FILE pointer in C# as an IntPtr. You can then import
such function using C# P/Invoke like so:
[ DllImport("YourLibrary.dll") ]
public static extern int myfunct(IntPtr filehandle);
Of course, you also need some other function the returns an usable
FILE* handle for you (I quickly made this up, dunno if it actually
works):
[ DllImport("msvcrt.dll", CharSet=CharSet.Auto) ]
public static extern IntPtr fopen(string file, string mode);