A
Ashutosh
pInvoke - arguments marshaling
Hi,
I am using pInvoke and the member function has signature like this in C++
int F1(ULONG handle, LPCTSTR s1, LPCTSTR s2, LPCTSTR s3, LPCTSTR s4)
so, I am using this signature in C#
public static extern int F1([MarshalAs(UnmanagedType.U8)] UInt64 handle,
[MarshalAs(UnmanagedType.LPTStr)]string s1,
[MarshalAs(UnmanagedType.LPTStr)]string s2,
[MarshalAs(UnmanagedType.LPTStr)]string s3,
[MarshalAs(UnmanagedType.LPTStr)]string s4);
So, if I call it like this
F1(1234,"Earth","Moon","Sun","");
then I am receiving these values in C++ dll
handle= 1234
s1= null
s2= Earth
s3= Moon
s4= Sun
The arguments seems to be shifted.
If I remove the ULONG from the declaration at both place, everything
works fine.
ULONG is 64 bit unsigned int. So, it should be passed as U8!! So, whats
wrong here???
Please advice!!
Ashutosh
Hi,
I am using pInvoke and the member function has signature like this in C++
int F1(ULONG handle, LPCTSTR s1, LPCTSTR s2, LPCTSTR s3, LPCTSTR s4)
so, I am using this signature in C#
public static extern int F1([MarshalAs(UnmanagedType.U8)] UInt64 handle,
[MarshalAs(UnmanagedType.LPTStr)]string s1,
[MarshalAs(UnmanagedType.LPTStr)]string s2,
[MarshalAs(UnmanagedType.LPTStr)]string s3,
[MarshalAs(UnmanagedType.LPTStr)]string s4);
So, if I call it like this
F1(1234,"Earth","Moon","Sun","");
then I am receiving these values in C++ dll
handle= 1234
s1= null
s2= Earth
s3= Moon
s4= Sun
The arguments seems to be shifted.
If I remove the ULONG from the declaration at both place, everything
works fine.
ULONG is 64 bit unsigned int. So, it should be passed as U8!! So, whats
wrong here???
Please advice!!
Ashutosh