Interop question C#
-
Hi, anyone has an idea of how to call a function with the following signature long csp2TimeStamp2Str(unsigned char *Stamp, char *value, long nMaxLength) in C# I declare it like this [DllImport("csp2.dll", EntryPoint="csp2TimeStamp2Str")] public static extern int csp2TimeStamp2Str( [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder blah, [MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer, int maxLength); Thanks in advance
-
Hi, anyone has an idea of how to call a function with the following signature long csp2TimeStamp2Str(unsigned char *Stamp, char *value, long nMaxLength) in C# I declare it like this [DllImport("csp2.dll", EntryPoint="csp2TimeStamp2Str")] public static extern int csp2TimeStamp2Str( [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder blah, [MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer, int maxLength); Thanks in advance
hi pl check like this:- [DllImport("csp2.dll",EntryPoint="csp2TimeStamp2Str",ExactSpelling=false,SetLastError=true)] public static extern int csp2TimeStamp2Str(out char stamp,out char value,int maxLength); regards, pubudu.
-
Hi, anyone has an idea of how to call a function with the following signature long csp2TimeStamp2Str(unsigned char *Stamp, char *value, long nMaxLength) in C# I declare it like this [DllImport("csp2.dll", EntryPoint="csp2TimeStamp2Str")] public static extern int csp2TimeStamp2Str( [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder blah, [MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer, int maxLength); Thanks in advance
Do you have any documentation? The first parameter
unsigned char *Stamp
might be 1. a pointer to a simple value, possibly taken from an enumerationref char stamp
ref short stamp
[MarshalAs(UnmanagedType.U2)] ref YourEnumType stamp
2. a [In] null-terminated unicode string[MarshalAs(UnmanagedType.LPWStr)] string stamp
3. a [Out/maybe In] null-terminated unicode string[MarshalAs(UnmanagedType.LPWStr)] StringBuilder stamp
4. a [In] data array, its length is given in parameter nMaxLength[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] char[] stamp
5. a [Out] data array, its length is the return value of the functionIntPtr stamp
This goes for the second parameter as well, except for the last two possibilities, one is an [Out] parameter, the other one is an [In] parameter. Without some documentation it is very hard to tell. Mark