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. I have a question about invoke function in C++ dll, please help! [modified]

I have a question about invoke function in C++ dll, please help! [modified]

Scheduled Pinned Locked Moved C#
questioncsharpc++data-structureshelp
3 Posts 3 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.
  • W Offline
    W Offline
    warrior
    wrote on last edited by
    #1

    hi, I want to invoke a function from a C++ dll in C#, the function prototype as follows: void F(Matrix &H,double (*ptr)[2]); the prototype of Matrix as follows: typedef struct { double array[3][3]; } Matrix; How to pass the parameter Matrix &H and double (*ptr)[2] to F? Any help will be appreciated!

    modified on Thursday, April 3, 2008 5:40 AM

    P N 2 Replies Last reply
    0
    • W warrior

      hi, I want to invoke a function from a C++ dll in C#, the function prototype as follows: void F(Matrix &H,double (*ptr)[2]); the prototype of Matrix as follows: typedef struct { double array[3][3]; } Matrix; How to pass the parameter Matrix &H and double (*ptr)[2] to F? Any help will be appreciated!

      modified on Thursday, April 3, 2008 5:40 AM

      P Offline
      P Offline
      papadimitriou
      wrote on last edited by
      #2

      you are looking for P/Invoke , you must use dllimport (and many more) look it up on google and msdn , good luck with this you will need it . you must declere the functions as static using dllimport attribute dll function [DllImport("SectionDBEngine.dll", EntryPoint = "getHeadersByIndex")] public static extern int getHeadersByIndex([In, Out] CSectionHeader[] headers, int size); http://msdn2.microsoft.com/en-us/library/aa288468.aspx[^]

      f(yf) = yf

      1 Reply Last reply
      0
      • W warrior

        hi, I want to invoke a function from a C++ dll in C#, the function prototype as follows: void F(Matrix &H,double (*ptr)[2]); the prototype of Matrix as follows: typedef struct { double array[3][3]; } Matrix; How to pass the parameter Matrix &H and double (*ptr)[2] to F? Any help will be appreciated!

        modified on Thursday, April 3, 2008 5:40 AM

        N Offline
        N Offline
        nelo_
        wrote on last edited by
        #3

        I can tell you that you'll have to re-define the struct on the .NET side for sure. The second parameter seems like an array of doubles. Is that so? That will map to System.Array.

        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