I've added a marshaller modifier for bool on my parameters too. I've noticed
something strange, if I pass a False value to my pinvoke, the C calls receives a
value of 0x01 and not 0x00 as I expected? I'm I doing something wrong?
My pinvoke is defined as:
.method public hidebysig static pinvokeimpl("libcursor.dll" ansi)
void Fdui0ly([in] native int hwnd,
[in] int32 bar_flag,
[in] bool marshal( int8) show_flag) cil managed
preservesig
{
)
And on the call site in .NET I have something like:
.method public hidebysig newslot virtual
instance void my_call([in] native int hwnd,
[in] int32 bar_flag) cil managed
{
// Code size 9 (0x9)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldc.i4 0
IL_0003: call void MyClass::Fdui0ly(native int, int32, bool)
IL_0008: ret
} // end of method WelWindow::CwinShowScrollBar
Manu
Mattias Sj?gren - 10 Dec 2003 00:46 GMT
Emmanuel,
>Does it make the operation faster?
I don't know, I haven't done any perf testing.
>I've added a marshaller modifier for bool on my parameters too. I've noticed
>something strange, if I pass a False value to my pinvoke, the C calls receives a
>value of 0x01 and not 0x00 as I expected? I'm I doing something wrong?
I think this is a runtime bug, but I can't remember the exact details.
It seems to work correctly in Whidbey though.
But for parameters, since the unsigned char still occupies 32 bits on
the stack, I believe you might as well use the default marshaling and
leave out marshal(int8).
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.