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. On calling a function written in c from a dotnet c# application

On calling a function written in c from a dotnet c# application

Scheduled Pinned Locked Moved C#
csharpvisual-studiohelptutorial
3 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.
  • U Offline
    U Offline
    User 4753359
    wrote on last edited by
    #1

    HI, i ve written an application in dotnet c#(visual studio 2005) which requires to call a function written in c(this is part of other application). So please help me on how to call this function.

    C 1 Reply Last reply
    0
    • U User 4753359

      HI, i ve written an application in dotnet c#(visual studio 2005) which requires to call a function written in c(this is part of other application). So please help me on how to call this function.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      your C function can be called as part of a dll using P/invoke. You have an app in C, not C++ ? It works the same way, anyhow, so long as it's in a dll. To call the function within a running app, you need to use WM_COPYDATA or something to set up interprocess communication.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      U 1 Reply Last reply
      0
      • C Christian Graus

        your C function can be called as part of a dll using P/invoke. You have an app in C, not C++ ? It works the same way, anyhow, so long as it's in a dll. To call the function within a running app, you need to use WM_COPYDATA or something to set up interprocess communication.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        U Offline
        U Offline
        User 4753359
        wrote on last edited by
        #3

        hi, now i ve been able to call the function from the c# application. I made the dll and in the *.def file i ve exported this particular function. Then in my c# application using [dllimport(*.dll}], i called the function and i was successful in that, Now according to the c application as soon as this function is called it populates a structure with some values and ultimately i want these values. So now after successfully calling this function how can i get the structure values????Pls help

        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