Opague structures (such as file/window handles) can be passed to/from
PInvoke via the System.IntPtr type. You should be able to do this without
the need for unsafe code blocks...
I assume, but dunno off the top of my head, that there is some way to get a
file handle from a .NET stream - if not then you can PInvoke the CreateFile()
& CloseHandle() APIs... In any event you'll probably want to remember to
implement the IDispose pattern to clean up your file handle...
"Usenet User" wrote:
I have an API DLL with a handful of methods, which I wrapped in
DllImport-attributed methods in C#.
Everything works fine, however, one of the methods takes an open file
handle (as an int) to write its execution log into.
Is there a way in .NET to create such a handle to pass to the method?
TIA!