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

Interop

Scheduled Pinned Locked Moved C#
comquestion
2 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.
  • G Offline
    G Offline
    grv575
    wrote on last edited by
    #1

    If I have the C code: beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput); can I just use ...(..., short[] Samples, ...) or do I need pSamples to be an IntPtr? If you want to check out the simple code (a wav -> mp3 encoder) it's located at http://www.geocities.com/grv575/encode.zip I don't see what's wrong besides maybe the gc moving the managed arrays around if that's what causing the encode method to fail.

    F 1 Reply Last reply
    0
    • G grv575

      If I have the C code: beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput); can I just use ...(..., short[] Samples, ...) or do I need pSamples to be an IntPtr? If you want to check out the simple code (a wav -> mp3 encoder) it's located at http://www.geocities.com/grv575/encode.zip I don't see what's wrong besides maybe the gc moving the managed arrays around if that's what causing the encode method to fail.

      F Offline
      F Offline
      firat kocak
      wrote on last edited by
      #2

      Hi, To pass unknown length arrays as parameters is not allowed in C#. You have to inform the length of it to the function and use something like below, [MarshalAs(UnmanagedType.ByValArray, SizeConst=TheLengthOfArray] ..... your function declaration ( ..., byte [] Samples,.... ) But if the length of the array has not a constant value then you need to find the address of your byte array and then use that address to pass to your function cheers, Doing something is better than doing nothing. So ... Move !

      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