How marshall byte* ?
-
I have a library FPLIB.DLL with have the following function: DLLEXPORT DWORD WINAPI FPMGetImage(BYTE* buffer); How I declare my access in C#? What is byte* ? [DllImport("fplib.dll", EntryPoint="FPMGetImage", SetLastError=true, CharSet=CharSet.Ansi, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)] public static extern int FPMGetImage(:confused: buffer); Thanks for all help! Alexsander "Axia" Antunes
-
I have a library FPLIB.DLL with have the following function: DLLEXPORT DWORD WINAPI FPMGetImage(BYTE* buffer); How I declare my access in C#? What is byte* ? [DllImport("fplib.dll", EntryPoint="FPMGetImage", SetLastError=true, CharSet=CharSet.Ansi, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)] public static extern int FPMGetImage(:confused: buffer); Thanks for all help! Alexsander "Axia" Antunes
byte* is a pointer to a byte structure. And need to be compiled in an
unsafe
block. You can try usingref
in the decleration to get around the pointer. Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure... -
byte* is a pointer to a byte structure. And need to be compiled in an
unsafe
block. You can try usingref
in the decleration to get around the pointer. Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure...Have you an example of API Windows with use BYTE*? Because I use API Viewer 2003 and I can compare the sintax. Alexsander "Axia" Antunes
-
Have you an example of API Windows with use BYTE*? Because I use API Viewer 2003 and I can compare the sintax. Alexsander "Axia" Antunes
I asked somthing like this the other day, heres what Heath Stewert told me: >Instead of passing byte* as the parameter, declare your parameter using either ref or out >for value types (like a Byte). This is the most common method. > >For instance, if the C functions is declared like so:void SomeFunc(byte* b); >...declare your method like so:[DllImport("...")]private static extern void SomeFunc(ref byte b); >Microsoft MVP, Visual C# >My Articles Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure...
-
I asked somthing like this the other day, heres what Heath Stewert told me: >Instead of passing byte* as the parameter, declare your parameter using either ref or out >for value types (like a Byte). This is the most common method. > >For instance, if the C functions is declared like so:void SomeFunc(byte* b); >...declare your method like so:[DllImport("...")]private static extern void SomeFunc(ref byte b); >Microsoft MVP, Visual C# >My Articles Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure...
OK!
[DllImport("fplib.dll", EntryPoint="FPMGetImage", SetLastError=true, CharSet=CharSet.Ansi, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)] public static extern int FPMGetImage([In, Out] byte[] buffer);
This code run perfectly! THANKS FOR ALL!! Matthew Hazlett wrote: I asked somthing like this the other day, heres what Heath Stewert told me: >Instead of passing byte* as the parameter, declare your parameter using either ref or out >for value types (like a Byte). This is the most common method. > >For instance, if the C functions is declared like so:void SomeFunc(byte* b); >...declare your method like so:[DllImport("...")]private static extern void SomeFunc(ref byte b); >Microsoft MVP, Visual C# >My Articles Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure... Alexsander "Axia" Antunes