PInvoke, marshalling bool as int

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I'm writing the interop functions for functions in a C dll. All these functions return INT (32 signed). However, the return value is to be interpreted as a bool (false=0, true!=0). Can I do the following without problems

[DllImport("UsedLib.dll", EntryPoint="UsedFn")
[return : MarshalAs(UnmanagedType.I4)
public static extern bool UsedFn( )

Thank yo
 
I'm writing the interop functions for functions in a C dll. All these
functions return INT (32 signed). However, the return value is to be
interpreted as a bool (false=0, true!=0). Can I do the following without
problems?
[DllImport("UsedLib.dll", EntryPoint="UsedFn")]
[return : MarshalAs(UnmanagedType.I4)]
public static extern bool UsedFn( );

Yes, I've used methods that define the return value as bool when it's really
an int.

n!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top