Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How marshall byte* ?

How marshall byte* ?

Scheduled Pinned Locked Moved C#
questioncsharphelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alexsander Antunes
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • A Alexsander 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

      M Offline
      M Offline
      Matthew Hazlett
      wrote on last edited by
      #2

      byte* is a pointer to a byte structure. And need to be compiled in an unsafe block. You can try using ref in the decleration to get around the pointer. Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure...

      A 1 Reply Last reply
      0
      • M Matthew Hazlett

        byte* is a pointer to a byte structure. And need to be compiled in an unsafe block. You can try using ref in the decleration to get around the pointer. Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure...

        A Offline
        A Offline
        Alexsander Antunes
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • A Alexsander 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

          M Offline
          M Offline
          Matthew Hazlett
          wrote on last edited by
          #4

          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...

          A 1 Reply Last reply
          0
          • M Matthew Hazlett

            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...

            A Offline
            A Offline
            Alexsander Antunes
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups