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. recieving UCHAR buffer in C# from C DLL

recieving UCHAR buffer in C# from C DLL

Scheduled Pinned Locked Moved C#
csharptutorial
1 Posts 1 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
    A T I F
    wrote on last edited by
    #1

    I have a C DLL that defines a structure like this struct Data { int iLength; UCHAR *buff; // ... other data }; void AllocateData(Data *pData); void FreeData(Data *pData); The buffer inside the structure is allocated inside the C DLL and the buffer lenght is provided in the iLength upon return. I want to use by creating C# marshalling layer to these function in C#. I have the declaration like this [ StructLayout( LayoutKind.Sequential )] public struct Data { public int iLength; //dont know what to use for UCHAR buffer // I tried byte[] buff; but it gives exceptions. //.. other data } [ DllImport( "Data.dll", EntryPoint="AllocateData", ExactSpelling=true, // Bypass A or W suffix search CharSet=CharSet.Ansi, // We want ANSI String CallingConvention=CallingConvention.Cdecl ) ] public static extern void AllocateData(ref Data data); I cannot understand what to use for UCHAR pointer and how to allocate the structure before calling the DLL function.

    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